tags:

views:

115

answers:

2

HI am new to ASP.NET MVC and I am running into some issues trying to deploy a very simple site! I took the MVC Storefront (Kona), made some basic changes and now I would like to deploy it to a webserver! For testing, I just turned on IIS7 on my windows 7 desktop! I change the web projects settings to use local IIS and run it!

The first issue I get is the "Request is not available in this context"... To fix this I had to remove the HttpContext.Current.GetSiteUrl() in the global.asx.cs file! If I now run the app it works but I have no css? If I switch back to VS development server everything works great?

I can also swithc from integrated mode on IIS to classic which makes the css work but then I have no routing?

+1  A: 

On IIS 7, HttpContext.Current is null in Application_Start because it isn't triggered by the first request anymore.

You can work around that issue by moving the code from Application_Start to Application_BeginRequest and add a flag to indicate if the application is already initialized (member of the Global class). When false, execute the code that uses HttpContext.Current and set the flag to true so subsequent requests don't execute that piece of code.

martijnboland
A: 

Hi, Doing what is said above fixed the css for me but adding this to

http://blogs.msdn.com/mikeormond/archive/2008/11/06/and-getting-asp-net-routing-up-and-running-in-web-applications-and-on-iis7.aspx Fixed the routing for me. Good luck took me long enough!

DJRodriguez