How can I achieve multi-lingual server errors in an ASP.NET application?

不问归期 提交于 2020-01-13 13:49:28

问题


My ASP.NET web application has the following section in web.config:

  <system.webServer>
    <httpErrors errorMode="Custom">
      <remove statusCode="500" subStatusCode="-1" />
      ...
      <error statusCode="500" prefixLanguageFilePath="httpErrors\custom" path="500.htm" responseMode="File" />
    ...
    </httpErrors>

My application directory contains the following files:

  • httpErrors\custom\en-US\500.htm
  • httpErrors\custom\de-DE\500.htm

These two files are identical except for their content language.

I now add a simple aspx file called errorsim.aspx to the root of my site to return a 500 status code for testing. Here are the contents:

<%@ Page Language="C#" %>
<script runat="server">
protected void Page_Init(object sender, EventArgs e)
{
    Response.Clear();
    Response.StatusCode = 500;
    Response.End(); 
}
</script>

When I browse to local.domain.com/errorsim.aspx from my local development machine (which is configured with en-GB globalisation settings) I see the 500.htm from the en-US directory which I assumed was therefore a default. However, after installing a Chrome extension to simulate requests from German localization culture, I'm still seeing the en-US content.

Am I doing something wrong here? Please note that I'm trying to handle errors statically without any .NET processing.

来源:https://stackoverflow.com/questions/40178743/how-can-i-achieve-multi-lingual-server-errors-in-an-asp-net-application

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!