2015-02-08 23:31:05 +08:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
2014-09-05 18:34:16 +08:00
|
|
|
|
using System.Text.RegularExpressions;
|
2015-02-08 23:31:05 +08:00
|
|
|
|
using System.Web;
|
|
|
|
|
|
|
|
|
|
namespace Web12306
|
|
|
|
|
{
|
|
|
|
|
public class CrxHandler:IHttpHandler
|
|
|
|
|
{
|
|
|
|
|
#region Implementation of IHttpHandler
|
|
|
|
|
|
2014-09-05 18:34:16 +08:00
|
|
|
|
#if !DEBUG
|
|
|
|
|
|
2015-02-08 23:31:05 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// 通过实现 <see cref="T:System.Web.IHttpHandler"/> 接口的自定义 HttpHandler 启用 HTTP Web 请求的处理。
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="context"><see cref="T:System.Web.HttpContext"/> 对象,它提供对用于为 HTTP 请求提供服务的内部服务器对象(如 Request、Response、Session 和 Server)的引用。</param>
|
|
|
|
|
public void ProcessRequest(HttpContext context)
|
|
|
|
|
{
|
|
|
|
|
var request = context.Request;
|
|
|
|
|
var response = context.Response;
|
|
|
|
|
|
2014-09-05 18:34:16 +08:00
|
|
|
|
var ua = request.UserAgent;
|
|
|
|
|
if (string.IsNullOrEmpty(ua))
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
var m = Regex.Match(ua, @"Chrome/(\d+)", RegexOptions.IgnoreCase);
|
|
|
|
|
if (!m.Success)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
var v = int.Parse(m.Groups[1].Value);
|
|
|
|
|
|
|
|
|
|
if (v < 34)
|
|
|
|
|
{
|
|
|
|
|
response.Redirect("http://www.fishlee.net/service/dcl/44");
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
response.Redirect("http://www.fishlee.net/service/dcl/60");
|
|
|
|
|
}
|
|
|
|
|
|
2015-02-08 23:31:05 +08:00
|
|
|
|
}
|
|
|
|
|
|
2014-09-05 18:34:16 +08:00
|
|
|
|
#else
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 通过实现 <see cref="T:System.Web.IHttpHandler"/> 接口的自定义 HttpHandler 启用 HTTP Web 请求的处理。
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="context"><see cref="T:System.Web.HttpContext"/> 对象,它提供对用于为 HTTP 请求提供服务的内部服务器对象(如 Request、Response、Session 和 Server)的引用。</param>
|
|
|
|
|
public void ProcessRequest(HttpContext context)
|
|
|
|
|
{
|
|
|
|
|
var request = context.Request;
|
|
|
|
|
var response = context.Response;
|
|
|
|
|
|
|
|
|
|
var ua = request.UserAgent;
|
|
|
|
|
if (string.IsNullOrEmpty(ua))
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
var m = Regex.Match(ua, @"Chrome/(\d+)", RegexOptions.IgnoreCase);
|
|
|
|
|
if (!m.Success)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
response.Redirect("crx.crx");
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
#endif
|
2015-02-08 23:31:05 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// 获取一个值,该值指示其他请求是否可以使用 <see cref="T:System.Web.IHttpHandler"/> 实例。
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns>
|
|
|
|
|
/// 如果 <see cref="T:System.Web.IHttpHandler"/> 实例可再次使用,则为 true;否则为 false。
|
|
|
|
|
/// </returns>
|
|
|
|
|
public bool IsReusable {
|
|
|
|
|
get { return false; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
}
|
|
|
|
|
}
|