源码网商城,靠谱的源码在线交易网站 我的订单 购物车 帮助

源码网商城

asp.net 站点URLRewrite使用小记

  • 时间:2021-06-11 15:57 编辑: 来源: 阅读:
  • 扫一扫,手机访问
摘要:asp.net 站点URLRewrite使用小记
IIS收到请求-->ISAPI用于处理该请求-->BeginRequest开始-->EndRequest结束-->输出Response 中间有好多其它的流程就不标记了,这里只是列出URLRewrite所走的流程。 其实就是在BeginRequest事件中调用HttpContext的RewritePath方法,将该请求重新“定位”至一个目标URL就完成了。 在站点的Global.asax文件BeginRequest方法中添加代码:
[u]复制代码[/u] 代码如下:
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"); } } }
  • 全部评论(0)
联系客服
客服电话:
400-000-3129
微信版

扫一扫进微信版
返回顶部