Base solution for your next web application
Ends in:
01 DAYS
01 HRS
01 MIN
01 SEC
Open Closed

It can't show the 'Error.cshtml' view. #1400


User avatar
0
coolshun created

I download the Multi Page Web Application template project from ABP website.I write " <system.web> <customErrors mode="On" /></system.web>" in "<configuration>" of webconfig,and write "throw new System.Exception("A sample exception message...");" in "Index()" action method of "UsersController.cs". then I see "http://localhost:61759/Users" in Edge,but it con't show the custom error page,it show the aps.net error page with yellow color.

why?


5 Answer(s)
  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    It's not configured by default.

    You can create a common ErrorController, create an Index action for it and configure it like this,

    <customErrors mode="On" defaultRedirect="~/Error">
    </customErrors>
    

    In the Index action of ErrorController, return Error.cshml or create a cutom error page of yours.

  • User Avatar
    0
    coolshun created

    Hi, Thanks! But in the document,it says that the ABP will handling exceptions automatically,the document url :http://www.aspnetboilerplate.com/Pages/Documents/Handling-Exceptions

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    You are right, I misunderstand the situation.

    The problem is UsersController is not inherited from "[YourProjectName]ControllerBase". If you inherit UsersController controller from "[YourProjectName]ControllerBase" just like LayoutController does, ABP will handle your exception as well.

    We will also fix this for the next release,

    Thank you for informing us.

  • User Avatar
    0
    coolshun created

    Hi, Thanks! I edit the "UserController" as your say,it can redirect the error view now.Can I popup the error view instead of redirect?By this way ,the user can keep the info inputed.

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    If you are making an ajax request, errors should be displayed as modal dialogs. But if you are making url redirect, it will show Error page.

    You can use ajax requests in your case.