MVC3处理catch块中的异常并抛出异常

时间:2013-07-19 11:49:41

标签: asp.net-mvc asp.net-mvc-3 exception-handling

我想了解如何处理MVC3中的休息服务特定异常。有什么指针吗? 基本上,我有一个Controller,可能有多个try catch块和throw语句用于异常。 阅读完所有帖子后我有点困惑。 编辑:

public ActionResult Index()
    {
        IConsumerRequest conReq = oSession.Request();
        conReq = conReq.Get();
        conReq = conReq.ForUrl(Session["ServiceEndPoint"].ToString());
        try
        {
            conReq = conReq.SignWithToken();
        }
        catch (Exception ex)
        {
            throw ex;
        }

       return View();
    }

在抛出异常时,我需要能够重定向到自定义错误页面。 我也读了这篇文章: Custom error pages on asp.net MVC3 但如果我的应用程序没有在IIS上运行,我如何处理不同的错误代码,如302或其他任何错误代码。

1 个答案:

答案 0 :(得分:2)

Bellow是自定义exp处理的好链接

Click Here