Running ASP.NET MVC application behind a proxy with different root relative path

Posted by Wiebe on Stack Overflow See other posts from Stack Overflow or by Wiebe
Published on 2010-04-07T10:08:03Z Indexed on 2010/04/07 10:23 UTC
Read the original article Hit count: 229

Filed under:
|
|
|
|

Hi All,

I'm having trouble with paths in a ASP.NET MVC application that's running behind a proxy.

Our IIS Application root path is for example http://server/MyApp/

meaning that all urls using the application root ("~/",Url.Action("MyAction","MyController")) are resolved to "/MyApp"

Now we're running behind a proxy server that forwards all requests, but changes the application root to something like this: "/Secury/Proxy/RubbishUrl/MyApp"

Because the original url is only available on the client, I thought of creating a cookie with the path prefix, and insert this before each generated URL on the server.

Now the question is, what's the best location in code to modify each URL that's resolved/sent to the client (to resources, controller actions, images etc)?

Every path in the application is resolved with the MVC methods (Url.Content, Url.Action etc).

© Stack Overflow or respective owner

Related posts about c#

Related posts about ASP.NET