【问题标题】:iis 7 /asp.net doesn't obey error pages settings on .net4 web siteiis 7 /asp.net 不遵守 .net4 网站上的错误页面设置
【发布时间】:2011-07-23 21:54:47
【问题描述】:

我刚刚在我的日志中注意到,如果有一个“。”在 .net 4 集成应用程序池上不存在的 url 末尾,iis 7.5 不显示您预设的 404 url​​,但默认未找到页面。

我在 iis 和 asp.net 设置中都有我的自定义 404 url​​。它适用于任何其他不存在的网址。

站点使用 .net 4 路由和 asp.net 网络表单。据我所知,这与路由无关,因为即使我尝试使用“site.com/djfdhfhgfhgfggfff”之类的随机网址。行为不会改变。

有人遇到过这种情况吗?

错误看起来像是来自 asp.net。上面写着

Server Error in '/' Application.
The resource cannot be found. 
Description: HTTP 404. The resource you are looking for (or one of its dependencies)  could have been removed, had its name changed, or is temporarily unavailable.  Please review the following URL and make sure that it is spelled correctly. 

Requested URL: /etc.

更新:刚刚完成了跟踪记录,看起来像是 global.asax 正在抛出它。

MODULE_SET_RESPONSE_ERROR_STATUS 
ModuleName global.asax 
Notification 1 
HttpStatus 404 
HttpReason Not Found 
HttpSubStatus 0 
ErrorCode 0 
ConfigExceptionInfo  
Notification BEGIN_REQUEST 
ErrorCode The operation completed successfully. (0x0) 

【问题讨论】:

  • 它可能因为点而通过 ASP.NET 处理程序路由,这意味着您的 ASP.NET 页面会引发此错误。 ASP.NET 有哪些通配符映射?
  • 没有更改 iis 上与映射相关的任何内容。我在下面的路线上注意到了它,但是没有路线它也会做同样的事情 routes.MapPageRoute("tag", "tag/{Keyword}/{PageNumber}", "~/tags.aspx", false, new RouteValueDictionary { { "PageNumber", "1" } } );

标签: asp.net http-status-code-404 iis-7.5 asp.net-routing


【解决方案1】:

基本上,您从 ASP.NET 而不是 IIS 获得 404 代码。一个简单的解决方法是通过 web.config 中的部分告诉 asp.net 使用您的自定义页面来处理 404 错误。请参阅此链接中的示例...http://msdn.microsoft.com/en-us/library/h0hfz6fc.aspx

【讨论】:

  • 嗯。你觉得我错过了什么?
  • 我刚试过这个。我能够获得 404 页面的自定义 IIS 版本,而不是 asp.net 404 错误页面。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2013-08-10
  • 1970-01-01
  • 2022-06-15
  • 2012-09-19
  • 1970-01-01
  • 2011-01-14
  • 2016-11-30
相关资源
最近更新 更多