1

In my MVC 3 app, I'm trying to show custom 404 pages. I've got the 403 pages to work, by returning a HttpStatusCodeResult. However, 404's are handled by MVC, and evidently, something is being done differently. Here's my configuration.

<system.web>
    <customErrors mode="RemoteOnly" defaultRedirect="/Pages/Error.aspx" redirectMode="ResponseRewrite">
        <error statusCode="404" redirect="/Pages/404.aspx" />
        <error statusCode="403" redirect="/Pages/403.aspx" />
        <error statusCode="500" redirect="/Pages/error.aspx" />
    </customErrors>
</system.web>
<system.webServer>
    <httpErrors errorMode="Custom">
        <remove statusCode="403" />
        <remove statusCode="404" />
        <remove statusCode="500" />

        <error statusCode="403" path="/Pages/403.aspx" responseMode="ExecuteURL" />         
        <error statusCode="404" path="/Pages/404.aspx" responseMode="ExecuteURL" />
        <error statusCode="500" path="/Pages/errors.aspx" responseMode="ExecuteURL" />
    </httpErrors>
</system.webServer>

This is on my dev machine at the moment: IIS 7.5 on Windows 7

Any suggestions on the right way to configure this?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.