MVC中的错误异常 [英] Error exception in MVC

查看:98
本文介绍了MVC中的错误异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,



i想要显示任何错误或异常的错误信息。



我在Global.asax中编写了以下代码



hello,

i want to show error message for any error or exception occures.

I have written follwing code in Global.asax

void Application_Error(object sender, EventArgs e)
       {
           Response.Write("<Error message...");
       }





但不起作用。我已经把dubug点放在这个方法上,但这也没有用。



在web.config中< customErrors mode =RemoteOnly /> 已设置。



任何人都知道问题是什么。



问候,

Viprat



but its not working. I have put dubug point on this method but that is also not working.

In the web.config <customErrors mode="RemoteOnly"/> is set.

Anyone havbe idea what is the problem.

Regards,
Viprat

推荐答案

添加如下方法

Add your method like below
 protected void Application_Error(object sender, EventArgs e)
        {
            Response.Write("<error message...");

}



我建议你按照以下链接中的异常处理说明

MVC中的异常处理 [ ^ ]

希望这有助于


I recommend you to follow the exception handling explain in the below link
Exception Handling in MVC[^]
Hope this helps


这篇关于MVC中的错误异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆