Click here to Skip to main content
15,899,754 members
Please Sign up or sign in to vote.
3.50/5 (2 votes)
See more:
Hi,
I am trying to set Custom error page in my project.I have the actual link http://localhost:2900/musiccreations/Default.aspx.If i am deleting .aspx from that link it should show me 404 page not found my custom error page.I did but its work only on my local pc.Its not working in server.Here is the code that i used
<customErrors mode="On" defaultRedirect="Error.aspx">
            <error statusCode="404" redirect="404.aspx" />
            
        </customErrors>

please help me out how to set this ...
Posted
Comments
Anupam Singh_ 13-May-14 3:11am    
does your 404.aspx file exist in root directory?
if not , put it into root directory(else mentioned complete path of it).
SanSkun 13-May-14 3:18am    
Yaa its there in root directory.

Try following

XML
<?xml version="1.0"?>
<configuration>
   <system.web>
     .. existing text ..
     .. existing text ..
   </system.web>
   <system.webServer>
      <httpErrors>
        <remove statusCode="401" subStatusCode="-1" />
        <remove statusCode="403" subStatusCode="-1" />
        <remove statusCode="404" subStatusCode="-1" />
        <remove statusCode="500" subStatusCode="-1" />
          <!-- full url when responsemode is Redirect -->
        <error statusCode="401" path="http://foo.com/default.htm" responseMode="Redirect" />
          <!-- local relative path when responsemode is ExecuteURL -->
        <error statusCode="403" path="/errors/403.htm" responseMode="ExecuteURL" />
        <error statusCode="404" path="/somedir/oops404.htm" responseMode="ExecuteURL" />
        <error statusCode="500" path="/somedir/500.asp" responseMode="ExecuteURL" />
      </httpErrors>
      <modules runAllManagedModulesForAllRequests="true"/>
   </system.webServer>
</configuration>


Above code snippet copied from following link

web-config-custom-httperrors[^]
 
Share this answer
 
Please try is as below.

XML
<customErrors mode="RemoteOnly" defaultRedirect="~/ErrorPages/Oops.aspx">
    <error statusCode="404" redirect="~/ErrorPages/404.aspx" />
</customErrors>


Read this for more info : Displaying a Custom Error Page
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900