Default error pages may expose a lot of information, Like the language and the server you use, and such Info. could be used by malicious users to attack your site and your server.
Also default error pages look very ugly and outdated design, which may harm your brand.
So It's always recommended to use custom error pages..
So, How Could I display a custom error page in DNN when error occurs ?
1.To Disable DNN Error Handling, and Let Errors Bubble..
Host Settings >> Appearance >> Un-Check "Use Custom Error Messages? "
2.To Redirect Users To, Can be aspx page, but I prefer HTML
Then Create HTML Page at the root with Style
3.in Enable CustomErrors in Web.Config :
<customErrors mode="On">
<error statusCode="500" redirect="/MyCustomError.html"/>
<error statusCode="404" redirect="/MyCustomError.html"/>
<error statusCode="403" redirect="/MyCustomError.html"/>
</customErrors>
Also You can Override IIS Error Pages and Redirect to your Custom Error Pages using the below web.config snippet
<httpErrors>
<remove statusCode="404" subStatusCode="-1"/>
<error statusCode="404" prefixLanguageFilePath="" path="/MyCustomError.aspx" responseMode="ExecuteURL"/>
<remove statusCode="403" subStatusCode="-1"/>
<error statusCode="403" prefixLanguageFilePath="" path="/MyCustomError.html" responseMode="ExecuteURL"/>
</httpErrors>
Related
As stated in the title i need to configure a custom web page for 404 error in my site (made with ASP.NET) and hosted on IIS.
To do so, i configure web.config as follow :
<httpErrors>
<remove statusCode="404" subStatusCode="-1" />
<error statusCode="404" prefixLanguageFilePath="" path="/mycustompath/404.html" responseMode="ExecuteURL" />
</httpErrors>
Everything work just fine, if i type :
https://mydomain/path/page.aspx__somethingwrong__
i correctly go to my custom 404.html
Same happen if i put some random character instead of file
But if i mess up with the path, or type an unexisting .aspx file, then IIS redirect me to default 404 page. And is not clear to me why.
Example of url that does not work :
https://mydomain/invalid_path/page.aspx
https://mydomain/path/fictional_page.aspx
You can add errorMode="Custom" and existingResponse="Replace" in the web.config file to solve your problem.
<httpErrors errorMode="Custom" existingResponse="Replace">
<remove statusCode="404" subStatusCode="-1" />
<error statusCode="404" prefixLanguageFilePath="" path="/MyErrorPages/404.html" responseMode="ExecuteURL" />
</httpErrors>
existingResponse specifies what happens to an existing response when the HTTP status code is an error, It also has 3 options:
auto(Default) : Leaves the response untouched only if the SetStatus
flag is set.
Replace : Replaces the existing response even if the SetStatus flag
is set. (means using custom page anyway)
Passthrough : Leaves the response untouched if an existing response
exists.
I am trying to setup custom error for my website which works fine on local-host mode="On".
But same fails on actual website.
Below is my code for web.config
<customErrors mode="RemoteOnly" defaultRedirect="~/error/Message.aspx?msg=The page you requested could not be found.">
<error statusCode="404" redirect="~/error/Default.aspx?PID=32"/>
<error statusCode="403" redirect="~/error/Forbidden.aspx"/>
<error statusCode="400" redirect="~/error/Error.aspx"/>
<error statusCode="500" redirect="~/error/InternalError.aspx"/>
</customErrors>
I am using IIS 7.5 on my local machine and same is being used on the web server.
Do i need to change any specific setting on Production server to make it work
Error message i am still getting on live website for 404
Not Found
The requested document was not found on this server.
Web Server at xyz.com
Final version with following code worked
...
<customErrors mode="RemoteOnly" defaultRedirect="~/error/Message.aspx?msg=The page you requested could not be found.">
<error statusCode="404" redirect="~/error/Default.aspx?PID=32"/>
<error statusCode="403" redirect="~/error/Forbidden.aspx"/>
<error statusCode="400" redirect="~/error/Error.aspx"/>
<error statusCode="500" redirect="~/error/InternalError.aspx"/>
</customErrors>
....
<system.webServer>
<httpErrors errorMode="Custom" existingResponse="Replace">
<remove statusCode="404" subStatusCode="-1" />
<error statusCode="404" path="/error/Default.aspx?PID=32" responseMode="ExecuteURL"/>
</httpErrors>
</system.webServer>
the web.config part seems to be ok, even if I would suggest static html for default error page redirection.
How do you test this issue on remote server?
By typing url xyz.com/xxxxxx where xxxxxx is page which not exist?
If yes, so is xxxxxx without file extension?
And does 404 redirect works if xxxxx ends with file extension which is one of website default page? e.g. xxxx.aspx
Try this post
asp.net custom error page and file without extension
Currently I am using UrlRewritingNet.UrlRewrite dll for URL rewriting in Asp.Net #3.5.
Without using any special character it works fine ex. URL1.
But after giving special characters in URL it throws Bad Request error ex. URL2
URL1: http://www.example.com/search/0253
URL2: http://www.example.com/search/0253:0253
To handle this error, I want to redirect it to some other Error Page, How can I do this?
On IIS 7+ you can define error pages for all statuses, for 400 Bad Request :
<httpErrors>
<error statusCode="400" path="/bad-request.aspx" prefixLanguageFilePath="" responseMode="ExecuteURL"/>
</httpErrors>
or trough IIS console go to the error pages and add custom error page for status code 400 :
The best way is by using Web.config file like
<system.web>
<!-- other system.web stuff -->
<customErrors defaultRedirect="/Error404.aspx" mode="On" redirectMode="ResponseRewrite">
<error redirect="/Error404.aspx" statusCode="404" />
</customErrors>
</system.web>
<system.webServer>
<!-- other system.webServer stuff -->
<httpErrors errorMode="Custom">
<remove statusCode="404" subStatusCode="-1" />
<error statusCode="404" prefixLanguageFilePath="" path="/Error404.aspx" responseMode="ExecuteURL" />
</httpErrors>
</system.webServer>
For more details click here
I am working on DNN 7.0. I create a ErrorPage.aspx and set it as defaultredirect and another page 404error.aspx and set it with the status code 404.
now if i access the website like
www.abc.com/testing.aspx , and testing.aspx donot exists, it takes me to 404error.aspx page
then i try to access my website by
www.abc.com/testing , now it is showing that ugly asp.net error.
need some assistance what am i doing wrong, or what i am missing.
Thanks
Got it working.
In web.config implemented httpErrors and CustomErros tag
like
<httpErrors errorMode="Custom">
<remove statusCode="404" subStatusCode="-1" />
<error statusCode="404" path="/404Error.aspx" responseMode="ExecuteURL" />
</httpErrors>
and
<customErrors mode="On" defaultRedirect="/CustomErrorPage.aspx">
</customErrors>
I have set up a page to handle errors that occur in a website I work on using web.config. I have used the customErrors section in web.config to do this, as described here
Here is the relevant section
<customErrors mode="On" defaultRedirect="page.aspx?IDDataTreeMenu=357">
<error statusCode="403" redirect="page.aspx?IDDataTreeMenu=357"/>
<error statusCode="404" redirect="page.aspx?IDDataTreeMenu=357" />
</customErrors>
This seems to work for all errors except 404. I just get the standard IIS 404 error when accessing a URL that doesn't exist.
What am I missing here?
This site is hosted on a shared server, so changing settings in IIS is not an option
Check with the ISP and see if they have a place where you can insert a reference to your own custom 404 page.
At Network Solutions they give you a control panel and a page where you can set this up.
<httpErrors>
<clear />
<error statusCode="404" subStatusCode="-1" path="/404.asp" responseMode="ExecuteURL" />
</httpErrors>