0
votes

I have an ASP.Net MVC 2 web application where I have HomeController. Index method generates unauthorized exception. I have customErrors=on. Now I want to show a view Error.aspx in shared folder with Exception.Message. But I get Resource not found /Error in browser.

Note: I had gone through all the related links on StackOverflow.

any help?

1
Please post some code how you use the custom error attribute. And note that by default the attribute load the default error.aspx view. So be sure you don't have delete it.sra

1 Answers

2
votes

Step by step:

  1. Create a new ASP.NET MVC project using the default visual Studio wizard
  2. Modify the HomeController so that it looks like this:

    [HandleError]
    public class HomeController : Controller
    {
        public ActionResult Index()
        {
            throw new Exception("oops");
        }
    }
    
  3. Add the following to the <system.web> section of web.config:

    <customErrors mode="On" />
    
  4. Run the application

  5. As expected the ~/Views/Shared/Error.aspx is shown