재우니의 블로그

ASP.NET MVC 에서 CUSTOM 에러 발생 처리 방안

 

 

<system.web>

<customErrors mode="On" defaultRedirect="/Html/ErrorPage/Error500.htm"></customErrors>

</system.web>

 

 

 

<system.webServer>
    <modules>
      <remove name="FormsAuthentication" />
      <remove name="WebDAVModule" />
    </modules>



    <httpErrors errorMode="Custom">
      <remove statusCode="401" subStatusCode="-1" />
      <remove statusCode="403" subStatusCode="-1" />
      <remove statusCode="404" subStatusCode="-1" />
      <remove statusCode="405" subStatusCode="-1" />
      <remove statusCode="500" subStatusCode="-1" />
      <remove statusCode="501" subStatusCode="-1" />
      <remove statusCode="502" subStatusCode="-1" />      
      <error statusCode="401" prefixLanguageFilePath="" path="/Html/ErrorPage/Error401.htm" responseMode="ExecuteURL" />
      <error statusCode="403" prefixLanguageFilePath="" path="/Html/ErrorPage/Error403.htm" responseMode="ExecuteURL" />
      <error statusCode="404" prefixLanguageFilePath="" path="/Html/ErrorPage/Error404.htm" responseMode="ExecuteURL" />
      <error statusCode="405" prefixLanguageFilePath="" path="/Html/ErrorPage/Error405.htm" responseMode="ExecuteURL" />
      <error statusCode="500" prefixLanguageFilePath="" path="/Html/ErrorPage/Error500.htm" responseMode="ExecuteURL" />
      <error statusCode="501" prefixLanguageFilePath="" path="/Html/ErrorPage/Error500.htm" responseMode="ExecuteURL" />
      <error statusCode="502" prefixLanguageFilePath="" path="/Html/ErrorPage/Error500.htm" responseMode="ExecuteURL" />
    </httpErrors>

<system.webServer>

 

 

https://stackoverflow.com/a/27204219

 

HTTP Error 404.0 - Not Found in MVC 5

My project in MVC 5.i wanted to handel 404. i did it but problem is that When I access the view using the following URL, everything works fine and as expected: http://localhost/Hotels/Index30701...

stackoverflow.com