C# 可能的错误-Asp.net路由本地化线程出现奇怪问题
我有两个页面A和B。根据Web.Conf中的区域性设置,这两个页面都应该使用适当的全局资源显示文本 在A页上,我能够根据文化背景将文本可视化,所以在本例中是法语 页面A还有一个链接,它使用GetUrl创建指向页面B的Url路由 B页:C# 可能的错误-Asp.net路由本地化线程出现奇怪问题,c#,asp.net,routing,C#,Asp.net,Routing,我有两个页面A和B。根据Web.Conf中的区域性设置,这两个页面都应该使用适当的全局资源显示文本 在A页上,我能够根据文化背景将文本可视化,所以在本例中是法语 页面A还有一个链接,它使用GetUrl创建指向页面B的Url路由 B页: <asp:Literal ID="uxLatestGuides" runat="server" Text="<%$ Resources:Global, LatestGuides %>" /&
<asp:Literal ID="uxLatestGuides"
runat="server"
Text="<%$ Resources:Global, LatestGuides %>" />
Web.Config
<?xml version="1.0"?>
<configuration>
<system.web>
<pages enableViewState="false" theme="Cms-FE-00" >
</pages>
<globalization culture="fr" uiCulture="fr"/>
</system.web>
</configuration>
我找到了这个问题的解决办法 分析Global.asax.cs路由时,我注意到虚拟URL主题/{TitleUrl},它将映射到物理URL~/Cms/FrontEndCms/CategoryList.aspx 在我指定的情况下,我将Web.Config文件放在~/Cms/FrontEndCms/中,因此当在诸如mysite.com/topic/my-page这样的路由URL页面上创建链接时,Web.Config将不在正确的位置,而是在另一个文件夹中,因此我的区域性设置将不适用 解决方案是将Web.Config移动到我的网站的根目录,这样它将应用于所有路由。希望可以帮助别人
<asp:Literal ID="uxLatestGuides"
runat="server"
Text="<%$ Resources:Global, LatestGuides %>" />
protected void Application_BeginRequest(object sender, EventArgs e)
{
var check1 = Thread.CurrentThread.CurrentCulture;
var check2 = Thread.CurrentThread.CurrentUICulture;
}
<?xml version="1.0"?>
<configuration>
<system.web>
<pages enableViewState="false" theme="Cms-FE-00" >
</pages>
<globalization culture="fr" uiCulture="fr"/>
</system.web>
</configuration>
routes.MapPageRoute("TopicHub", "topic/{TitleUrl}", "~/Cms/FrontEndCms/CategoryList.aspx");