shashank
shashank

Reputation: 47

Custom error in web.config not working for 404

I am trying to set up custom error for my website, which works fine on my local machine but it fails on the server. Below is my code.

<system.web>
    <customErrors  mode="On" defaultRedirect="~/Pages/Error.aspx">       
      <error statusCode="404" redirect="~/Pages/PageNotFound.aspx"/>      
    </customErrors>
</system.web>

<system.webServer>

    <httpErrors errorMode="Custom" existingResponse="PassThrough"defaultResponseMode="ExecuteURL">
      <remove statusCode="404" subStatusCode="-1" />
      <error statusCode="404" prefixLanguageFilePath="" path="~/Pages/PageNotFound.aspx" responseMode="ExecuteURL"/>
    </httpErrors>

</system.webServer>

I am using IIS 8 on my local server and IIS 7 on the live server. Should I change this code in any way to make it work?

Also, when I try to access a page, eg: xyz.aspx, it does'nt show anything except for a white browser window.

Upvotes: 1

Views: 1914

Answers (1)

user3442830
user3442830

Reputation: 40

Check if you have more then one web config Or Check your web config file is inside your project correctly.

Upvotes: 1

Related Questions