未在 GetRouteData (System.Web.Routing) 中设置对象引用

发布于 2024-07-21 07:08:50 字数 1067 浏览 6 评论 0原文

这让我抓狂。 我已经在 Web 表单应用程序上实现了 Web.Routing。 应用程序工作正常,然后莫名其妙地(至少目前)抛出以下错误消息:

对象引用未设置为 对象的实例。 在 System.Web.Routing.RouteCollection.GetRouteData(HttpContextBase httpContext)位于 System.Web.Routing.UrlRoutingModule.PostResolveRequestCache(HttpContextBase 上下文)在 System.Web.Routing.UrlRoutingModule.OnApplicationPostResolveRequestCache(对象 发送者、EventArgs e) at System.Web.HttpApplication.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() 在 System.Web.HttpApplication.ExecuteStep(IExecutionStep 步骤,布尔值& 同步完成)

此错误是间歇性的,无论在网站上进行多少次导航都不会重新创建该错误。

我对该错误的解释是,对服务器的请求会导致带有 null httpContext 的 PostResolveRequestCache 事件,但我不确定这是怎么可能的。

通过重新启动应用程序池即可解决该问题。

该应用程序在 IIS6 上运行,因此,我已将通配符应用程序映射添加到 aspnet_isapi.dll,并且未选中“验证该文件存在”。 这是为了启用没有文件扩展名的友好 URL,但是我正在考虑更改此设置作为可能的解决方法。 这背后的想法是,可能有一个请求被发送到服务器,而该服务器正在拾取不应该的模块。

我的实施是定制的,但遵循 Haack 先生制定的一般准则。 由于错误的性质,我不确定我的代码是否能提供很多见解,但我显然愿意根据要求这样做。

任何帮助将非常感激。

This is driving me mad. I've implemented the Web.Routing on a Web Forms application. The application works fine and then inexplicably (at least at the moment) the following error message is thrown:

Object reference not set to an
instance of an object. at
System.Web.Routing.RouteCollection.GetRouteData(HttpContextBase
httpContext) at
System.Web.Routing.UrlRoutingModule.PostResolveRequestCache(HttpContextBase
context) at
System.Web.Routing.UrlRoutingModule.OnApplicationPostResolveRequestCache(Object
sender, EventArgs e) at
System.Web.HttpApplication.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
at
System.Web.HttpApplication.ExecuteStep(IExecutionStep
step, Boolean& completedSynchronously)

This error is intermittent and no amount of navigating around the site recreates the error.

My interpretation of the error is that a request to the server is resulting in a PostResolveRequestCache event with a null httpContext, but I'm not sure how that is possible.

The problem is resolved by restarting the Application Pool.

The application is running on IIS6, because of this, I've added a Wildcard application map to aspnet_isapi.dll with "Verify that file exists" unchecked. This is to enable friendly urls without file extensions, I am however considering changing this as a possible work around. The thinking behind this is, that there is possibly a request being sent to the server which is being picked up the module that shouldn't be.

My implementation has been customised but follows the general guidelines set down by Mr. Haack. Due to the nature of the error, I'm unsure whether any of my code would provide much insight, but I'm obviously willing to do so on request.

Any help would be much appreciated.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

赠佳期 2024-07-28 07:08:50

添加自定义文件扩展名并不理想,但可以防止出现更多错误消息。

Adding custom file extensions was not ideal but has prevented further error messages.

与之呼应 2024-07-28 07:08:50

可能与正在修改的路由集合有关。 请参阅其他问题

Might be related to the route collection being modified. See other question.

闻呓 2024-07-28 07:08:50

该错误与 .Net 中的集合不是线程安全的一致。

请查看我对这个类似问题的最新回答

That error is consistent with a collection not being thread-safe in .Net.

Kindly check out my last answer on this similar question

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文