Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/jquery-ui/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Asp.net mvc 如何在MVC中获取错误时重定向页面_Asp.net Mvc_Exception - Fatal编程技术网

Asp.net mvc 如何在MVC中获取错误时重定向页面

Asp.net mvc 如何在MVC中获取错误时重定向页面,asp.net-mvc,exception,Asp.net Mvc,Exception,我在MVC中遇到了这个错误。当我得到这个错误时,我想重定向一个错误页面。怎么办 错误是: 错误: 处理您的请求时出错 应用try catch块并在catch块中使用重定向代码重定向网页。。。我希望这将帮助您您可以随时使用try-catch 下面是一个例子。希望能有帮助 // action method for same [HttpPost] public ActionResult Save(EmployeeModel employeeModel) {

我在MVC中遇到了这个错误。当我得到这个错误时,我想重定向一个错误页面。怎么办

错误是:

错误:

处理您的请求时出错


应用try catch块并在catch块中使用重定向代码重定向网页。。。我希望这将帮助您

您可以随时使用try-catch

下面是一个例子。希望能有帮助

    // action method for same
    [HttpPost]  
    public ActionResult Save(EmployeeModel employeeModel)
    {

        try
        {
            // do something, like call a service/business layer method.

            // redirect to home action
             return RedirectToAction("Home");

        }
        catch (Exception ex)
        {
            // if failure gets into catch block and returns the posted model back, 
            // work aroud for viewstate(does not exist in asp.net mvc) using model binding in asp.net mvc
            return View(employeeModel);

        }
    }

请给我您的源代码。这是一个如此普遍的错误,任何人都不可能了解它的原因。我在应用程序中使用reportviewer,但在发布区域中并没有报告的dll引用。我处理try-catch块,但那个引用问题不属于catch块。只有那个错误发生了。