Reputation: 985
I've deployed MVC application to IIS 7.5 (Windows Server 2008 R2) successfully after some trouble with ASP.NET and dependencies and connections to database. I used import application feature of "Default Web Site".
This is my first time setting up IIS, so please bear with me.
It is set up at localhost/System. Now, I see that routing works because localhost/System (only /) gives my welcome view, and clicking login (localhost/System/Account/Login - /Accounts/Login) prompts me with login view.
Login populates menu from database, and all menu items are in this format: /Controller/Action/Values. When I click item in a menu, IIS issues a request localhost/Controller/Action - WITHOUT System. When I manually add system in the middle of request, naturally it works.
How am I to solve this?
I can easily change menu in database to add a /System prefix, but i have tons of same hard-coded addresses in java script all around the site. That would also mean that I am hard-coding the name of the site prior to deployment, and I don't like that.
Also, my site is completely white, as if IIS can't read my site.css file. It is located under /Content folder, and my site reference it like this:
<link href="@Url.Content("~/Content/Site.css")" rel="stylesheet" type="text/css" />
What are your suggestions, how sould i solve this?
UPDATE:
I've been looking though IIS logs, and here are few lines: GET /SYSTEM/Scripts/LookupJunction.js - 80 - ::1 Mozilla/5.0+(Windows+NT+6.1;+WOW64;+rv:15.0)+Gecko/20100101+Firefox/15.0.1 200 0 0 31 GET /SYSTEM/Content/Site.css - 80 - ::1 Mozilla/5.0+(Windows+NT+6.1;+WOW64;+rv:15.0)+Gecko/20100101+Firefox/15.0.1 200 0 0 31 GET /SYSTEM/Scripts/modernizr-1.7.min.js - 80 - ::1 Mozilla/5.0+(Windows+NT+6.1;+WOW64;+rv:15.0)+Gecko/20100101+Firefox/15.0.1 200 0 0 31 GET /SYSTEM/Content/2012.1.214/telerik.Office2007.min.css - 80 - ::1 Mozilla/5.0+(Windows+NT+6.1;+WOW64;+rv:15.0)+Gecko/20100101+Firefox/15.0.1 200 0 0 31 GET /SYSTEM/Content/2012.1.214/telerik.common.min.css - 80 - ::1 Mozilla/5.0+(Windows+NT+6.1;+WOW64;+rv:15.0)+Gecko/20100101+Firefox/15.0.1 200 0 0 46 GET /SYSTEM/Scripts/jquery-1.5.1.min.js - 80 - ::1 Mozilla/5.0+(Windows+NT+6.1;+WOW64;+rv:15.0)+Gecko/20100101+Firefox/15.0.1 200 0 0 46 GET /SYSTEM/Scripts/2012.1.214/telerik.common.min.js - 80 - ::1 Mozilla/5.0+(Windows+NT+6.1;+WOW64;+rv:15.0)+Gecko/20100101+Firefox/15.0.1 200 0 0 15 GET /SYSTEM/Scripts/2012.1.214/telerik.menu.min.js - 80 - ::1 Mozilla/5.0+(Windows+NT+6.1;+WOW64;+rv:15.0)+Gecko/20100101+Firefox/15.0.1 200 0 0 15 GET /SYSTEM/Scripts/2012.1.214/jquery-1.7.1.min.js - 80 - ::1 Mozilla/5.0+(Windows+NT+6.1;+WOW64;+rv:15.0)+Gecko/20100101+Firefox/15.0.1 200 0 0 31 GET /Content/drock028.jpg - 80 - ::1 Mozilla/5.0+(Windows+NT+6.1;+WOW64;+rv:15.0)+Gecko/20100101+Firefox/15.0.1 404 0 2 0 GET /SYSTEM/Content/2012.1.214/Office2007/sprite.png - 80 - ::1 Mozilla/5.0+(Windows+NT+6.1;+WOW64;+rv:15.0)+Gecko/20100101+Firefox/15.0.1 200 0 0 15 GET /Home/Test - 80 - ::1 Mozilla/5.0+(Windows+NT+6.1;+WOW64;+rv:15.0)+Gecko/20100101+Firefox/15.0.1 404 0 2 78
So, site.css is being loaded, but not my background image, it's path is missing 'SYSTEM' folder. I referenced it like this in my site.css:
background-image: url('/Content/drock028.jpg');
So, most of things get good urls, but not my background picture, and not calls to controller actions from database urls.
But, what should I do? I can't use URL helpers in database, nor can I use it in java script (or can I)?
Upvotes: 0
Views: 399
Reputation: 102793
For the first issue (URLs in the database), I would say leave the values in the format /Controller/Action, but update your views to render the application-relative URL:
@Url.Content("~" + url)
(So if the url from the database is /Home/Index, the above will give @Url.Content("~/Home/Index"), which will render /System/Home/Index.)
For the second part, as Nick noted, it might help to look at the Network tab in Firebug to see which URL is actually being requested for the CSS file (and whether it's getting a 404/Not Found, or something else). Your code for the CSS path is correct, so it may be an issue with the IIS configuration.
Upvotes: 1