I am using the IIS Url Rewrite module to rewrite urls for my ASP.Net web application. The Urls are being rewritten from:
http://domain/version/page.aspx
to
http://domain/company/page.aspx
And it works just fine when browsing directly using absolute paths. The problem comes in when navigating within the app using relative paths. any kind of relative path.
All relative paths redirect to the corresponding http://domain/version/page.aspx
instead of to the http://domain/COMPANY/page.aspx
that it should be going to.
I solved a lot of the issue by adding this line to the BeginRequest event in Global.asax:
Protected Sub Application_BeginRequest(ByVal sender As Object, ByVal e As System.EventArgs)
HttpContext.Current.RewritePath(HttpContext.Current.Request.Url.AbsolutePath, True)
End Sub
Essentially it is just rebasing the virtual path to the requested url.
But even with that Response.Redirect STILL redirects to the actual path and not the virtual path.
So this code: Response.Redirect("~/test.aspx")
will redirect to domain/Version/test.aspx
instead of domain/Company/test.aspx
How do I make Response.Redirect redirect to the virtual path (domain/COMPANY/test.aspx
) instead of to the actual path (domain/VERSION/test.aspx
)
Thanks.