views:

202

answers:

1

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 requires you to access the application through a URL like this: "/Secury/Proxy/RubbishUrl/MyApp"

Because the proxy 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).

A: 

You can create your own asp.net mvc controller factory where to decide which controller and action will serve the response based on the requested url. Check this url for a good blog post on how to do this - http://nayyeri.net/custom-controller-factory-in-asp-net-mvc.

Branislav Abadjimarinov
No, sorry it doesn't allow me to change/fix the URL's that are sent to the client. Please note that there is no notion of the URL that the proxy generates at all on the IIS server, as far as IIS is concerned the URL is still just http://server/MyApp/
Zidad