没有,自己增加一个呗在ASP.NET中实现和利用URL重写 Global.asax文件的Application_BeginRequest()方法
void Application_BeginRequest(object sender, EventArgs e)
{
string path = Request.Url.ToString();
if (Regex.IsMatch(path, "/URLRewriting/OldUrl.aspx", RegexOptions.IgnoreCase))
{
Context.RewritePath("/URLRewriting/NewUrl.aspx");
}
else if (Regex.IsMatch(path, "/URLRewriting/UserAccount/(.+).aspx", RegexOptions.IgnoreCase))
{
string idString = path.Substring(path.LastIndexOf('/') + 1, path.Length - path.LastIndexOf('/') - 6);
Context.RewritePath("/URLRewriting/UserAccount.aspx?id=" + idString); }
} 通过使用Request.Url属性来获得输入的URL路径,然后通过正则表达式来应用网站URL重写规则,匹配到期望的输入网址后,将它们重写成你希望转向的网址。
void Application_BeginRequest(object sender, EventArgs e)
{
string path = Request.Url.ToString();
if (Regex.IsMatch(path, "/URLRewriting/OldUrl.aspx", RegexOptions.IgnoreCase))
{
Context.RewritePath("/URLRewriting/NewUrl.aspx");
}
else if (Regex.IsMatch(path, "/URLRewriting/UserAccount/(.+).aspx", RegexOptions.IgnoreCase))
{
string idString = path.Substring(path.LastIndexOf('/') + 1, path.Length - path.LastIndexOf('/') - 6);
Context.RewritePath("/URLRewriting/UserAccount.aspx?id=" + idString); }
} 通过使用Request.Url属性来获得输入的URL路径,然后通过正则表达式来应用网站URL重写规则,匹配到期望的输入网址后,将它们重写成你希望转向的网址。
解决方案 »
- asp.net 怎样打开新窗口而不被阻止
- 如何查看当前注册的.net freamwork版本?
- 为什么这么简单的代码页会出错(已有打开的与此命令相关联的 DataReader,必须首先将它关闭。)
- GridView两个小问题!50分求解
- 如何让记录每天查看次数的字段到了晚上12点自动归零?
- <%# 网页中判断Session是否为空后显示:<%=if(Session["User"]!=null)"你好!"+Session["User"] %> 这样不行要如何写 谢谢
- 请教一个ASP发邮件的问题
- 如何得到當前項目的項目名稱或是自建的namespace名稱
- asp.net程序关闭远程桌面
- 我是初学者,怎样学.ASP,以前用过ASP,.ASP中用C#吗
- 求助关于字符串截取替换
- java和.NET网站共享注册用户
{
if (HttpContext.Current.Request.UserHostAddress == "127.0.0.1")
{
HttpContext.Current.Response.Write("已被屏蔽");
HttpContext.Current.Response.End();
} }
我自己写了一个,但是调试的时候设置断点,这段代码根本不会跳进去运行
void Application_Start(object sender, EventArgs e)
{
// 在应用程序启动时运行的代码
this.BeginRequest += new EventHandler(Global_BeginRequest);
}
void Global_BeginRequest(object sender, EventArgs e)
{
//throw new NotImplementedException();
}
Sub myBeginRequest(ByVal sender As Object, ByVal e As EventArgs) Handles Me.BeginRequest
Dim url As String = Request.Url.ToString
End Sub