Error when accessing IIS 7 server variable from ASP.Net MVC

Posted by StephSpr on Stack Overflow See other posts from Stack Overflow or by StephSpr
Published on 2010-03-19T21:17:50Z Indexed on 2010/03/19 21:21 UTC
Read the original article Hit count: 210

Filed under:
|

I have an ASP.Net MVC application which works fine on IIS 6.0 / Windows Server 2003. When installed on IIS 7.5 / Windows Server 2008 (integrated mode), it works but when the application attempts to generate an URL, it runs into the following error:

[NullReferenceException: Object reference not set to an instance of an object.] 
System.Web.HttpServerVarsCollection.Get(String name) +10960764 
System.Web.Mvc.PathHelpers.GenerateClientUrlInternal(HttpContextBase httpContext, String contentPath) +345 
System.Web.Mvc.PathHelpers.GenerateClientUrl(HttpContextBase httpContext, String contentPath) +80 
System.Web.Mvc.UrlHelper.GenerateUrl(String routeName, String actionName, String controllerName, RouteValueDictionary routeValues, RouteCollection routeCollection, RequestContext requestContext, Boolean includeImplicitMvcValues) +256 
System.Web.Mvc.UrlHelper.Action(String actionName, String controllerName, RouteValueDictionary routeValues) +36 

It looks like IIS7 fails to return the server name. There should be a configuration to set, but I couldn't find anything like that.

Do you have any idea to fix this issue ?

Thanks,

© Stack Overflow or respective owner

Related posts about ASP.NET

Related posts about iis7