How to redirect an error page in asp.net mvc

Hi friends. I have this code in my web configuration file. I am new to asp.net mvc.

<customErrors mode="On" defaultRedirect="~/Shared/Error">
      <error statusCode="403" redirect="~/Shared/Error" />
      <error statusCode="404" redirect="~/Shared/Error" />
    </customErrors>

and I have the Error.aspx page under the shared folder in my application.

Now My question is: do I need to do anything with the Global.ascx file for routing?

if so, how do you get directions? waht exactly needs to be defined in my global.ascx file ..

thank

+3
source share
2 answers

, . , , HandleError - ~/Views/Shared/ , .

[HandleError]
public class HomeController : Controller

. MSDN : http://msdn.microsoft.com/en-us/library/system.web.mvc.handleerrorattribute.aspx

+1

, . .

+1

Source: https://habr.com/ru/post/1755863/


All Articles