Shawn
Shawn

Reputation: 9402

.Net defaultRedirect to locale-specific error page

I have an ASP.Net webforms application that uses the .Net globalization features to deliver .aspx pages in different locales. I have custom errors defined as

 <customErrors mode="RemoteOnly" defaultRedirect="Error.htm">

I prefer using a non-.Net page for the defaultRedirect to prevent the potential for infinite loops, in case the error page itself generates an error, so I have targeted a static .htm page. However, I would like to render that page in the locale that the user originally requested, where the locale is determined from a querystring.

What is the best way to accomplish this?

I have considered these options, but I am interested in other options:

Upvotes: 1

Views: 1193

Answers (3)

Shawn
Shawn

Reputation: 9402

I have concluded that the best practice is to generally follow the method outlined in the answer to the following question, only transfer to a .htm page instead of an .aspx page:

ASP.NET 2.0 : Best Practice for writing Error Page

Upvotes: 0

Flavio CF Oliveira
Flavio CF Oliveira

Reputation: 5285

if you can create a dynamic page for error information, taking care about the localization and other things, i think that is the best way.

You can handle errors on global.asax our developing your own httpmodule (both ways are valid) you can manage the application errors by a great and dynamic way, taking control of all process.

including determine current laguage to decide about a possible redirect, or for example display different messages about different kind of errors.

in my opinion i start resolving a problem with a solution that givesme flexibility to deside how can i handle on different cases.

Upvotes: 0

MikeM
MikeM

Reputation: 27405

If your project file structure has language specific folders, one solution is to create a web.config with just the <customErrors /> section specified in each language folder

Example Project Structure

  • App_Code
  • ...
  • en-us
    • ...
    • web.config
  • en-gb
    • ...
    • web.config
  • zh-cn
    • ...
    • web.config
  • ...
  • Default.aspx
  • web.config

Upvotes: 1

Related Questions