[英]Programmatically Producing rewritten URLs?
Using IIS Rewrite over a ASP.NET 4.0 application. 使用IIS通过ASP.NET 4.0应用程序重写。 Is there some function I could call from within ASP.NET that would transform a string URL to the rewritten URL? 我可以在ASP.NET中调用一些将字符串URL转换为重写URL的函数吗? I would like to be able to do this in code-behind. 我希望能够在后台代码中执行此操作。
Something like this: string ProduceRewrittenUrl(string publicUrl)
像这样的东西: string ProduceRewrittenUrl(string publicUrl)
Yes this the HttpContext.Current.RewritePath(string)
是的,这是HttpContext.Current.RewritePath(string)
reference: http://msdn.microsoft.com/en-us/library/system.web.httpcontext.rewritepath.aspx 参考: http : //msdn.microsoft.com/zh-cn/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
. 一个全局调用它的位置是global.asax
上protected void Application_BeginRequest(Object sender, EventArgs e)
。
如果要在代码中执行此操作,请查看使用Global.asax的Application_BeginRequest()
事件。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.