Reputation: 47
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
Reputation: 40
Check if you have more then one web config Or Check your web config file is inside your project correctly.
Upvotes: 1