title: Can't find an Error page although an Error view exists ASP.NET MVC
body: <p>In an ASP.NET MVC web application I'm working on I am showing na Error view when there is an uncaught error in the application. In the Web.config:</p>
  
  <pre><code>&lt;customErrors mode="On" defaultRedirect="~/Error" /&gt;
  </code></pre>
  
  <p>Controller:</p>
  
  <pre><code> public class ErrorController : BaseController
  {
      public ActionResult Index()
      {
          return View();
      }
  }
  </code></pre>
  
  <p>And I have a view in folder Views/Error, Index.cshtml. Its content is not important for the issue I'm facing.</p>
  
  <p>When there is for example an error 404 everything works OK - the Error Index.cshtml page is shown(with the URL <code>http://localhost:51099/Error?aspxerrorpath=/Home/ssad</code>, which is OK) and in the application's error log the 404 error is reported. But when there is some other error, for example when I try to create a file in non-existing folder through my application, the Error Index.cshtml view is shown(with the URL <code>http://localhost:51099/Error?aspxerrorpath=/AdminDataExport/ResponseMatrix</code>, which is OK) but there are two errors reported - one that the folder cannot be found which is OK, and the other is:</p>
  
  <pre><code>The view 'Error' or its master was not found or no view engine supports 
  the searched locations. The following locations were searched:
  ~/Views/AdminDataExport/Error.aspx
  ~/Views/AdminDataExport/Error.ascx
  ~/Views/Shared/Error.aspx
  ~/Views/Shared/Error.ascx
  ~/Views/AdminDataExport/Error.cshtml
  ~/Views/AdminDataExport/Error.vbhtml
  ~/Views/Shared/Error.cshtml
  ~/Views/Shared/Error.vbhtml
  </code></pre>
  
  <p>Why does the application search for an Error file in this locations, when I have an ErrorController and a corresponding view defined? Why does this second error appear in some cases and in some don't?</p>
  
  <p>I want to fix the second error. I tried fixing it with adding an Error.cshtml file in the Views/Shared. The result is that the second error is not being logged which is what I want, but the URL is different from the first error - <code>http://localhost:51099/AdminDataExport/ResponseMatrix</code> and I want it to be <code>http://localhost:51099/Error?aspxerrorpath=/AdminDataExport/ResponseMatrix</code>. Is this possible?</p>