62,046
社区成员
发帖
与我相关
我的任务
分享
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;
using System.Text.RegularExpressions;
namespace BZone.Common
{
public class UserHttpHandler : IHttpHandler
{
#region IHttpHandler 成员
public bool IsReusable
{
get { return false; }
}
public void ProcessRequest(HttpContext context)
{
HttpRequest Request = context.Request;
//取Url的绝对路径
string Url = Request.Url.AbsolutePath;
int RegStart = Url.LastIndexOf("/") + 1;
//正则
Regex Reg = new Regex(@"[a-zA-Z,]*_p[\d]{1,10}t[\d]{1,10}.shtml");
if (Reg.IsMatch(Url.Substring(RegStart)))
{
context.Response.Write(Url.Substring(RegStart));
}
else
context.Response.Write("");
}
#endregion
}
}
webconfig:
<httpHandlers>
<add verb="*" path="*_p*t*.shtml" type="BZone.Common.UserHttpHandler,BZone.Common" />
</httpHandlers>