views:

50

answers:

3

I have a number of web applications within my website in IIS 7.5, in which my MVC2 web application will live.

WebSite
    * Prod
    * Test1
    * Test2

I have firewall routing configured to redirect from http://test1.mywebsite.com/xxx to http://my.actual.website/Test1

I've used Url.Content("~/Content/Site.css") but the CSS is not getting loaded. Looking at the source for the web page the url is being rendered as <link href="/Test1/Content/Site.css" ...>

Is there anything I can do to fix this? Possibly using the IIS URL rewriter module, or adding more rules to my firewall.

A: 

Sounds like the firewall also needs to be configured to redirect CSS and image requests too.

Simon Hughes
A: 

I would start by enabling Failed Request Tracing ( http://learn.iis.net/page.aspx/266/troubleshooting-failed-requests-using-tracing-in-iis-7/ ) in the server to see if it is getting the request and why. My guess it is getting resolved incorrectly so you could use URL Rewrite to fix the paths or maybe fix the links using the output rewrite functionality using URL Rewrite 2.0.

CarlosAg
+1  A: 

As you have applications (per environment) within your IIS website (rather than a single application in the route), ASP.NET MVC takes that into account when generating the URLs in Url.Content.

If you want to retain applications within your website, you can rewrite the URLs at the firewall level (if your firewall supports it), at the IIS level (URL Rewrite) or by implementing an alternative to Url.Content. Thanks to the source being available, you can see how the MVC framework does it and most of the work is done in the PathHelpers class.

Of course, if you then have additional work to develop/test/maintain your rewrite rules or your alternative URL generation code. My view would be to separate your applications so that you have a seperate application/environment per IIS website so that you don't have that additional burden.

Robin M