开发者

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

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 开发者_StackOverflow中文版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,

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜