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)
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
.
If you want to do it in code, take a look at using the Application_BeginRequest()
event of Global.asax.