1

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 

This error is raised when I call the Action method of an UrlHelper from a custom HTML helper I have created. The custom HTML Helper receives a reference to the UrlHelper object and uses it afterwards to generate URLs using the Action method. I noticed that when I call the Action method directly from the view, this error is not raised. However I didn't get from this difference the reason why it doesn't work on IIS7 -just a possible workaround.

Do you have any idea to fix this issue ?

Thanks,

renegadeMind
  • 4,073
  • 5
  • 29
  • 37
  • Can we have a blob of sample code? – Kev Mar 21 '10 at 05:14
  • Kev, I edited the post to give more explanation. I didn't add any code sample as you ask, since there is a lot of code from the assignment of the HTML Helper to the call to the UrlHelper.Action method. However the idea is that it fails when I call the UrlHelper.Action method from a custom HTML helper. Thank you –  Mar 23 '10 at 19:50
  • Somebody had a similar problem on here and solved it by uninstalling the URL Rewrite Module in IIS 7 - http://stackoverflow.com/questions/8996067/asp-mvc-net3-local-iis7-object-reference-error – robwilliams Oct 08 '12 at 14:39

0 Answers0