asp.net – 从域到www.domain的全局301重定向
发布时间:2020-12-16 00:04:48 所属栏目:asp.Net 来源:网络整理
导读:我可以使用Global.asax的开始请求重定向一切, 从mydomain.domain到www.mydomain.domain? 如果这个是真的,我该怎么做? 解决方法 protected void Application_PreRequestHandlerExecute(Object sender,EventArgs e){ string currentUrl = HttpContext.Curren
我可以使用Global.asax的开始请求重定向一切,
从mydomain.domain到www.mydomain.domain? 如果这个是真的,我该怎么做? 解决方法protected void Application_PreRequestHandlerExecute(Object sender,EventArgs e) { string currentUrl = HttpContext.Current.Request.Path.ToLower(); if(currentUrl.StartsWith("http://mydomain")) { Response.Status = "301 Moved Permanently"; Response.AddHeader("Location",currentUrl.Replace("http://mydomain","http://www.mydomain")); Response.End(); } } (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- asp.net – 输出缓存使用BOTH varybyparam和varybycustom
- asp.net – 即使在ssl上,在ViewState中存储信用卡和定价信息
- asp.net – 我如何做一个已经内置到dll中的程序集,特别是fl
- asp.net-core – 带有ASP.NET身份3的JWT承载令牌
- ASP.NET MVC 4的Windows身份验证 – 它如何工作,如何测试
- asp.net-mvc – 我的MVC 5 Identity 2项目中没有Applicatio
- asp.net-mvc – ASP.NET MVC中的动态范围验证2
- asp.net-mvc – 修改模型时更新视图
- asp.net-3.5 – 如何在用户控件上获取文本框的值
- 在ASP.Net ReportViewer中使用SSRS
推荐文章
站长推荐
- asp.net-mvc-5 – 如何在Asp.Net Identity Frame
- asp.net – 以编程方式将CSS类添加到ListItem
- asp.net – 诊断“请求超时”HttpExceptions
- 在ASP.net中组合和高速缓存多个JavaScript文件
- 在ASP.net中使用NVP API时,PayPal SetExpressChe
- Asp.Net Webforms Vs Asp.Net WebSite(Razor)Vs
- asp.net – 在运行时获取IIS绑定
- asp.net – 检查会话是否已超时
- asp.net – 如何按优先级或按字母顺序对Request.
- asp.net – 如何迭代通过自定义vb.net对象的每个
热点阅读