手机
当前位置:查字典教程网 >编程开发 >asp.net教程 >asp.net 站点URLRewrite使用小记
asp.net 站点URLRewrite使用小记
摘要:IIS收到请求-->ISAPI用于处理该请求-->BeginRequest开始-->EndRequest结束-->输出Response中间有...

IIS收到请求-->ISAPI用于处理该请求-->BeginRequest开始-->EndRequest结束-->输出Response

中间有好多其它的流程就不标记了,这里只是列出URLRewrite所走的流程。

其实就是在BeginRequest事件中调用HttpContext的RewritePath方法,将该请求重新“定位”至一个目标URL就完成了。

在站点的Global.asax文件BeginRequest方法中添加代码:

复制代码 代码如下:

public class Global : System.Web.HttpApplication

{

protected void Application_BeginRequest(object sender, EventArgs e)

{

HttpContext context = HttpContext.Current;

if (context.Request.Path.Equals("/demo", StringComparison.InvariantCultureIgnoreCase))

{

context.RewritePath("~/demoList.aspx");

}

}

}

【asp.net 站点URLRewrite使用小记】相关文章:

asp.net中List的使用方法

asp.net用url重写URLReWriter实现任意二级域名第1/2页

asp.net 操作excel的实现代码

asp.net 票据简单应用

asp.net使用ODP即oracle连接方式的的防注入登录验证程序

asp.net gridview代码绑定

asp.net下PageMethods使用技巧

asp.net Repeater中使用if的代码

.net get set用法小结第1/3页

asp.net HttpWebRequest自动识别网页编码

精品推荐
分类导航