Custom Error Page not shown
Hi,
A website done in sitefinity 5 is showing customised error page in my local machine.
This is the web.confiog code:
<customErrors mode="On" defaultRedirect="~/pages/404">
<error statusCode="404" redirect="~/pages/404"/>
</customErrors>
But in the server, it is not showing the error page. Is it related to IIS?
Instead of going to the custom 404.aspx page, it goes to the IIS 404 page.
Thanks.
I have trouble getting this to work reliably.
I am running standard extensionless URLs.
If I request www.mysite.com/missingpage.aspx then my custom 404 page works fine.
If I request www.mysite.com/missingpage then the default IIS 404 page is displayed.
I haven't managed to get to the bottom of why it behaves this way.
From what I've experienced (IIS6), it seems like IIS is handling your second request before it even gets to Sitefinity because it thinks its a folder that doesn't exist. I was able to circumvent this problem by writing a .ashx Handler and then pointing my IIS 404 error to my handler which would in turn get run by .NET/Sitefinity.
Not quite sure I follow that... if IIS rejects because it 'thinks' it's an invalid folder, then how could it pass ANY extensionless requests... everything would be invalid until Sitefinity handles it.
I am not sure of the exact cause, I just noticed the behavior. I noticed that my custom error section in my web.config wasn't handling in that situation. So I changed IIS's 404 page to a test page, In the case of the invalid extentionless url, it navigated to my test page. Once, I pointed IIS to my handler everything started working.
Hi guys,
Basically the easiest way to get your custom errors working in Sitefinity you need to modify the webconfig and configure IIS accordingly ( please check the attached screenshots ).
Also the bellow code can be used to perform a 404 redirect to a custom error page created in Sitefinity:
<
customErrorsmode
=
"On"
>
<
errorstatusCode
=
"404"
redirect
=
"error-404"
/>
</
customErrors
>
Kind regards,
Victor Velev
the Telerik team
Same problem here!
The only way it works is setting it as suggested by Victor via IIS (httperror level rather than customerror)...
customErrors tag just seems to get ignored no matter what combination I try...
<
customErrors
mode
=
"On"
redirectMode
=
"ResponseRewrite"
>
<
error
statusCode
=
"500"
redirect
=
"~/error/error.html"
/>
<
error
statusCode
=
"404"
redirect
=
"~/error/page-not-found.html"
/>
</
customErrors
>
404 CUSTOM PAGE - WORKS .ASPX & NON .ASPX URLS WORKS ON GODADDY SHARED WINDOWS HOSTING (IIS7 .net4)
Create a 404.html or 404.aspx file on your local main folder in your shared godaddy hosting.
-Web.Config File-
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="Main Rule" stopProcessing="true">
<match url=".*" />
<conditions logicalGrouping="MatchAll">
<add input="REQUEST_FILENAME" matchType="IsFile" negate="true" />
<add input="REQUEST_FILENAME" matchType="IsDirectory" negate="true" />
</conditions>
<action type="Rewrite" url="404.html or 404.aspx" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
I had trouble with this too and found that you have to add elements both to system.web/customErrors AND system.webServer/httpErrors. The first handles ASP.NET 404s (like a request to the non-existent /doesntexist.aspx page). The second handles requests to missing folders or files (like /bogus or /bogus.htm).
I wrote a blog post with a few more details: http://wp.me/p29W52-69