Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我在我的 MVC 网站中捕获 404 错误。我可以选择通过在 web.config 或 application_error 中添加 customerrors 元素来做到这一点,但我不知道哪个更好。两者有什么区别?
我建议您使用 application_error 方法。通过这种方式,您可以记录 404 请求数据,以便生成未来的报告。AFAIK,如果您使用 web.config 设置重定向请求,您将丢失此信息。