The i18n.LocalizingModule works wonderfully, however I cannot get my custom error pages to work any longer. I am trying to figure out how to make this work. Anyone have experince? They start working as soon as I remove i18n.LocalizingModule module from web config. Currently my http error section looks like this and works well without i18n.LocalizingModule
`
If you have a particular route that you want excluding from being localized by i18n, you can modify the i18n.LocalizedApplication.Current.UrlsToExcludeFromProcessing property value to do that.
An example of doing that is in the readme.
Perhaps try:
i18n.LocalizedApplication.Current.UrlsToExcludeFromProcessing = new Regex(@"(?:\.(?:less|css)(?:\?|$))|(?i:i18nSkip|glimpse|trace|elmah|sitemap|error)");
My custom error pages when I typed them in manually come up fine. {siteurl}/error/notfound/ and actually they are properly translated too which is what I want. But somehow i18n module is intercepting httpErrors configuration and not allowing it to go to /error/notfound/ page but instead is is showing actual 404 iis error.
"The resource cannot be found.
Description: HTTP 404. The resource you are looking for......":
I would like my custom error page to show up like it normally does when I manually type in {siteurl}/error/notfound/
As soon as I remove this i18n module, custom error page comes up fine when I type in some random url that does not exist.
Any other Idea? How does your custom error pages come up with this module installed? This is MVC 4.72 C# Project.
I've had custom errors turned off on my current site, but have turned them on and after a bit of playing around with the web.config settings managed to get a custom error page to work for 404s with i18n enabled.
Thank you for the feedback, my configuration is not set up exactly like yours but currently we are supporting many web sites with below configuration and all of them are working well with custom error pages. It is similar and my routes are also set up properly since error pages pull up with appropriate response codes.
I tried few other things and it is still not working, like I said, as soon as I remove of i18 module it works, I will see if it is something else in the way I am using i18 module. Thank you for your help.
`
<!-- existingResponse - Whether or not to enable custom error pages.
PassThrough - Allow the default MVC debug error page showing the full exception to display
Replace - Replace any error responses with custom error pages. -->
<httpErrors errorMode="Custom" existingResponse="Replace">
<!-- Redirect IIS 400 Bad Request responses to the error controllers bad request action. -->
<remove statusCode="400" />
<error statusCode="400" responseMode="ExecuteURL" path="/error/badrequest/" />
<!-- Redirect IIS 401 Unauthorized responses to the error controllers unauthorized action. -->
<remove statusCode="401" />
<error statusCode="401" responseMode="ExecuteURL" path="/error/unauthorized/" />
<remove statusCode="403" />
<!-- Redirect IIS 403.14 Forbidden responses to the error controllers not found action.
A 403.14 happens when navigating to an empty folder like /Content and directory browsing is turned off
See http://www.troyhunt.com/2014/09/solving-tyranny-of-http-403-responses.html -->
<error statusCode="403" subStatusCode="14" responseMode="ExecuteURL" path="/error/notfound/" />
<!-- Redirect IIS 403.501 and 403.502 Forbidden responses to a static Forbidden page.
This happens when someone tries to carry out a Denial of Service (DoS) attack on your site.
See http://www.iis.net/learn/get-started/whats-new-in-iis-8/iis-80-dynamic-ip-address-restrictions -->
<error statusCode="403" subStatusCode="501" responseMode="File" path="error\forbidden.html" />
<error statusCode="403" subStatusCode="502" responseMode="File" path="error\forbidden.html" />
<!-- Redirect IIS 403 Forbidden responses to the error controllers forbidden action. -->
<error statusCode="403" responseMode="ExecuteURL" path="/error/forbidden/" />
<!-- Redirect IIS 404 Not Found responses to the error controllers not found action. -->
<remove statusCode="404" />
<error statusCode="404" responseMode="ExecuteURL" path="/error/notfound/" />
<!-- Redirect IIS 405 Method Not Allowed responses to the error controllers method not allowed action. -->
<remove statusCode="405" />
<error statusCode="405" responseMode="ExecuteURL" path="/error/methodnotallowed/" />
<remove statusCode="500" />
<!-- Redirect IIS 500.13 Internal Server Error responses to a static Service Unavailable page.
A 500.13 occurs because the web server is too busy. The amount of traffic exceeds the Web site's configured capacity. -->
<error statusCode="500" subStatusCode="13" responseMode="File" path="error\serviceunavailable.html" />
<!-- Redirect IIS 500 Internal Server Error responses to the error controllers internal server error action. -->
<error statusCode="500" responseMode="ExecuteURL" path="/error/internalservererror/" />
<!-- Redirect IIS 503 Service Unavailable responses to a static Service Unavailable page. -->
<remove statusCode="503" />
<error statusCode="503" responseMode="File" path="error\serviceunavailable.html" />
<!-- Redirect IIS 504 Gateway Timeout responses to a static Gateway Timeout page. -->
<remove statusCode="504" />
<error statusCode="504" responseMode="File" path="error\gatewaytimeout.html" />
</httpErrors>
The i18n.LocalizingModule works wonderfully, however I cannot get my custom error pages to work any longer. I am trying to figure out how to make this work. Anyone have experince? They start working as soon as I remove i18n.LocalizingModule module from web config. Currently my http error section looks like this and works well without i18n.LocalizingModule `
If you have a particular route that you want excluding from being localized by i18n, you can modify the
i18n.LocalizedApplication.Current.UrlsToExcludeFromProcessing
property value to do that.An example of doing that is in the readme.
Perhaps try:
I tried this but it does not seem to do anything.
My custom error pages when I typed them in manually come up fine. {siteurl}/error/notfound/ and actually they are properly translated too which is what I want. But somehow i18n module is intercepting httpErrors configuration and not allowing it to go to /error/notfound/ page but instead is is showing actual 404 iis error.
"The resource cannot be found. Description: HTTP 404. The resource you are looking for......":
I would like my custom error page to show up like it normally does when I manually type in {siteurl}/error/notfound/ As soon as I remove this i18n module, custom error page comes up fine when I type in some random url that does not exist.
Any other Idea? How does your custom error pages come up with this module installed? This is MVC 4.72 C# Project.
I've had custom errors turned off on my current site, but have turned them on and after a bit of playing around with the web.config settings managed to get a custom error page to work for 404s with i18n enabled.
Route definitions:
There's an ErrorController with Index action method that returns the default view (/Views/Error/Index.cshtml).
The setting was got from this blog article: https://benfoster.io/blog/aspnet-mvc-custom-error-pages/
Also for clarification I don't have
error
in theUrlsToExcludeFromProcessing
property mentioned earlier.Thank you for the feedback, my configuration is not set up exactly like yours but currently we are supporting many web sites with below configuration and all of them are working well with custom error pages. It is similar and my routes are also set up properly since error pages pull up with appropriate response codes.
I tried few other things and it is still not working, like I said, as soon as I remove of i18 module it works, I will see if it is something else in the way I am using i18 module. Thank you for your help.
`
`