“找不到资源” 在 ASP.NET MVC 项目中访问 elmah.axd 时出错
我的 ASP.NET MVC 应用程序位于 IIS 6.0 webroot 文件夹中名为 Stuff 的文件夹中。 因此,我通过 http://localhost/Stuff/Posts 访问我的页面。 当我使用 Visual Studio 的内置网络服务器时,我让 EMLAH 工作。 现在,当我访问 http://localhost/Stuff/elmah.axd 时,我收到资源未找到错误。 谁能在这里指出我的错误! 这是配置文件条目,
<add verb="POST,GET,HEAD" path="elmah.axd" type="Elmah.ErrorLogPageFactory, Elmah"/> //Handler
<add name="ErrorMail" type="Elmah.ErrorMailModule, Elmah"/>
<add name="ErrorLog" type="Elmah.ErrorLogModule, Elmah"/>
<add name="ErrorFilter" type="Elmah.ErrorFilterModule, Elmah"/> //Module
My ASP.NET MVC application is within a folder called Stuff within IIS 6.0 webroot folder. So I access my pages as http://localhost/Stuff/Posts. I had EMLAH working while I was using the in-built webserver of Visual Studio. Now when I access http://localhost/Stuff/elmah.axd, I get resource not found error. Can anyone point my mistake here! Here is config file entry,
<add verb="POST,GET,HEAD" path="elmah.axd" type="Elmah.ErrorLogPageFactory, Elmah"/> //Handler
<add name="ErrorMail" type="Elmah.ErrorMailModule, Elmah"/>
<add name="ErrorLog" type="Elmah.ErrorLogModule, Elmah"/>
<add name="ErrorFilter" type="Elmah.ErrorFilterModule, Elmah"/> //Module
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
使用 IIS7,我发现我需要填充
web.config
的两个部分(system.web
和system.webServer
) - 请参阅 Elmah 无法使用 asp.net 网站。或许这也是有关系的。
Working with IIS7 I found I needed both sections of the
web.config
populated (system.web
ANDsystem.webServer
) - see Elmah not working with asp.net site.Perhaps this is related.
您是否在 global.asax 中添加了忽略 *.axd 路由?
Have you added an ignore *.axd routes in global.asax?
对于 Elmah,我们需要区分两件事:
首先,http 模块完成错误日志记录、电子邮件发送等所有工作。
其次,http 处理程序,显示错误日志页面和其他页面(rss...等)。
我遇到了 404 资源未找到的相同问题,因为我有一个奇怪的设置!
在我的开发机器(windows 7、iis 7)上,elmah 工作得非常顺利,因为应用程序池工作在集成管道模式下。 然而,在生产机器中,应用程序正在使用托管管道,我尽了最大努力让 elmah 工作,但毫无用处......
然后我想到了显示 UI(错误日志页面、RSS、错误详细信息)的想法,...) 使用常规 aspx 页面。
我下载了源代码,做了一些更改(抱歉 Atif,我被迫这样做,因为我需要最快的解决方案),然后在我的应用程序中,我创建了一个文件夹,在该文件夹下创建了继承自 Elmah 定义的页面的常规 aspx 页面。
该页面仅包含一行(例如:对于详细信息页面:<%@ Page Language="C#" Inherits ="Elmah.ErrorDetailPage"%>)
现在,无论 IIS 6/7 和它的工作就像一个魅力..它让我免于正确配置http处理程序和解决其工作问题的大麻烦! 此外,配置安全性要简单得多!
我不知道社区是否对此解决方案感兴趣(如果是,我准备发布我的完整更改)。
希望这能让您了解如何以替代方式解决问题(如果您需要修改后的 dll 以及如何使用它的完整说明,请告诉我!)
For Elmah, we need to differentiate between two things:
First the http modules doing all the work of error logging, emailing...etc.
Second, the http handlers, displaying the error log page and other pages (rss...etc.)
I was having the same problem of 404 resource not found because I have a weird setup!
on my development machine, (windows 7, iis 7 ) elmah was working like a charm because the application pool was working in the integrated pipeline mode. In the production machine, however, the application was using the managed pipeline and I tried all my best to make elmah work but it was all useless...
I then got the idea of displaying the UI (error log page, rss, error detail,...) using regular aspx pages.
I downloaded the source code, made some changes (sorry Atif, I was forced to do this because I needed the quickest solution) and then in my application , I created a folder under which I created regular aspx pages which inherits from Elmah defined pages.
The page only contains one line (ex: for the detail page: <%@ Page Language="C#" Inherits ="Elmah.ErrorDetailPage"%>)
Now, I was able to run Elmah regardless of IIS 6/7 and it is working like a charm.. and It saved me from a big headache of correctly configuring http handlers and troubleshooting its work! additionally, configuring security is much simpler!
I don't know if the community is interested in this solution (If so, I am ready to post my full changes).
Hope that this gives you an idea on how to solve the problem in an alternative way (and if you need the modified dll with complete instructions on how to use it, just tell me!)
如果您不想更改代码或
web.config
文件,请在 IIS 的应用程序池设置中将托管管道模式
设置为经典
。 然后您的axd.s
将像以前一样工作。In the application pool settings in IIS set
Managed Pipelin Mode
toClassic
if you don't want to change code or theweb.config
file. Youraxd.s
will then work as before.你能发布你的 web.config 的其余部分吗?
或者,如果您足够舒服,您可以确保 httpHandlers 和 httpModules (不是处理程序和模块)部分在 web.config 中正确填写吗?
Can you post the rest of your web.config?
Or, if you're comfortable enough, can you just ensure that the httpHandlers and httpModules (NOT handlers and modules) sections are filled in properly in the web.config?