locked
Setting up a 404 error page RRS feed

  • Question

  • User-770252936 posted

    Hey. 404 error page to set my web.config file as follows'm configuring.

    <?xml version="1.0" encoding="utf-8"?>
    
    <configuration>
      <system.web>
        <compilation debug="false" targetFramework="4.0" />
        <customErrors mode="RemoteOnly" redirectMode="ResponseRewrite" defaultRedirect="Error.html">
          <error statusCode="404" redirect="_Error404.cshtml" />
        </customErrors>
      </system.web>
    </configuration>

    error.html errors on the page when the page is opened.

    But the 404 error page does not work.

    Sunday, June 15, 2014 5:06 AM

Answers

  • User-1454326058 posted

    Hi kortmazsefa,

    As far as I know, the custom error that in the system.web section is just used for the current website. In other works, if a request don’t handled by current website, then the custom error is not used. So it just display 404 error page.

    For example, if the request URL is http://localhost:23776/Page1.cshtml, then if you use http://localhost:23776/Page11.cshtml, it will redirect to your error page. If the request URL is http://localhost:23776/Page11, then it will just display the 404 error page.

    For that scenario, I suggest that you could configure the custom error in the IIS too. If you are using the IIS Express, you could add the httpErrors section in the system.webServer setion.

     <httpErrors errorMode="Custom" defaultResponseMode="Redirect">
          <remove statusCode="401" subStatusCode="-1" />
          <error statusCode="404" subStatusCode="0" path="Error.cshtml" responseMode="ExecuteURL" />
        </httpErrors>

    Thanks

    Best Regards

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, June 16, 2014 4:35 AM

All replies

  • User-821857111 posted
    Remove the leading underscore from your error page's name. Web pages is configured not to serve direct requests for files with a leading underscore in their name.
    Sunday, June 15, 2014 8:18 AM
  • User-770252936 posted

    404.cshtml I have changed the name of the page. But, again, to çıkmakd Not Found page.

    Sunday, June 15, 2014 2:46 PM
  • User-1454326058 posted

    Hi kortmazsefa,

    As far as I know, the custom error that in the system.web section is just used for the current website. In other works, if a request don’t handled by current website, then the custom error is not used. So it just display 404 error page.

    For example, if the request URL is http://localhost:23776/Page1.cshtml, then if you use http://localhost:23776/Page11.cshtml, it will redirect to your error page. If the request URL is http://localhost:23776/Page11, then it will just display the 404 error page.

    For that scenario, I suggest that you could configure the custom error in the IIS too. If you are using the IIS Express, you could add the httpErrors section in the system.webServer setion.

     <httpErrors errorMode="Custom" defaultResponseMode="Redirect">
          <remove statusCode="401" subStatusCode="-1" />
          <error statusCode="404" subStatusCode="0" path="Error.cshtml" responseMode="ExecuteURL" />
        </httpErrors>

    Thanks

    Best Regards

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, June 16, 2014 4:35 AM
  • User2129316869 posted

    I was about to Post a question on this but this one already helped. Thanks to all contribution.

    Wednesday, June 18, 2014 4:48 AM