简体   繁体   English

ASP.NET 4 Web表单路由和页面资源

[英]ASP.NET 4 web forms routing and page resources

I'm creating a ASP.NET 4 web forms application, which is multi-lingual. 我正在创建一个多语言的ASP.NET 4 Web窗体应用程序。 All is going well, and I've been creating local resource files for each page in the App_LocalResources sub-folder of each application folder and this all works fine. 一切进展顺利,我已经在每个应用程序文件夹的App_LocalResources子文件夹中为每个页面创建本地资源文件,并且一切正常。

However I've now added some extra forms which are using routing, and these no longer pickup the resource file. 但是,我现在添加了一些其他使用路由的表格,这些表格不再提取资源文件。

For example if I have a file /application/project/edit.aspx I would normally place an App_LocalResources folder within the /application/project folder and create edit.aspx.resx etc. However if this page is accessed via a route eg. 例如,如果我有一个文件/application/project/edit.aspx,我通常会在/ application / project文件夹中放置一个App_LocalResources文件夹,并创建edit.aspx.resx等。但是,如果通过例如路径访问此页面。 /application/project/1/edit then the local resource file is no longer used, I guess because the URL doesn't match with the resource file. / application / project / 1 / edit,则不再使用本地资源文件,我猜是因为URL与资源文件不匹配。

Is there any way around this, short of creating resource files in App_GlobalResources for the routed pages? 除了在App_GlobalResources中为路由页面创建资源文件之外,还有什么方法可以解决? For example can you define which resource files to use for a page in it's code-behind? 例如,您可以在代码隐藏的页面中定义要用于页面的资源文件吗?

My bad. 我的错。

I must be going blind, as I'd actually dropped the resx files for the page into the wrong App_LocalResource folder (a directory level up). 我一定是瞎了,因为我实际上是将页面的resx文件放到了错误的App_LocalResource文件夹(目录级别上升)中。

I need sleep... 我要睡觉了

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM