Programmatically Producing rewritten URLs?

六月ゝ 毕业季﹏ 提交于 2019-12-10 12:17:14

问题


Using IIS Rewrite over a ASP.NET 4.0 application. Is there some function I could call from within ASP.NET that would transform a string URL to the rewritten URL? I would like to be able to do this in code-behind.

Something like this: string ProduceRewrittenUrl(string publicUrl)


回答1:


Yes this the HttpContext.Current.RewritePath(string)

reference: http://msdn.microsoft.com/en-us/library/system.web.httpcontext.rewritepath.aspx

a global place to call it is the protected void Application_BeginRequest(Object sender, EventArgs e) on global.asax.




回答2:


If you want to do it in code, take a look at using the Application_BeginRequest() event of Global.asax.



来源:https://stackoverflow.com/questions/10837682/programmatically-producing-rewritten-urls

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!