久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

  1. <small id='vDjXh'></small><noframes id='vDjXh'>

  2. <i id='vDjXh'><tr id='vDjXh'><dt id='vDjXh'><q id='vDjXh'><span id='vDjXh'><b id='vDjXh'><form id='vDjXh'><ins id='vDjXh'></ins><ul id='vDjXh'></ul><sub id='vDjXh'></sub></form><legend id='vDjXh'></legend><bdo id='vDjXh'><pre id='vDjXh'><center id='vDjXh'></center></pre></bdo></b><th id='vDjXh'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='vDjXh'><tfoot id='vDjXh'></tfoot><dl id='vDjXh'><fieldset id='vDjXh'></fieldset></dl></div>

      <bdo id='vDjXh'></bdo><ul id='vDjXh'></ul>
  3. <legend id='vDjXh'><style id='vDjXh'><dir id='vDjXh'><q id='vDjXh'></q></dir></style></legend><tfoot id='vDjXh'></tfoot>

      App_LocalResources 如何與 MVC 一起工作?

      How does the App_LocalResources work with MVC?(App_LocalResources 如何與 MVC 一起工作?)
      <i id='XTNkS'><tr id='XTNkS'><dt id='XTNkS'><q id='XTNkS'><span id='XTNkS'><b id='XTNkS'><form id='XTNkS'><ins id='XTNkS'></ins><ul id='XTNkS'></ul><sub id='XTNkS'></sub></form><legend id='XTNkS'></legend><bdo id='XTNkS'><pre id='XTNkS'><center id='XTNkS'></center></pre></bdo></b><th id='XTNkS'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='XTNkS'><tfoot id='XTNkS'></tfoot><dl id='XTNkS'><fieldset id='XTNkS'></fieldset></dl></div>
      • <bdo id='XTNkS'></bdo><ul id='XTNkS'></ul>
              <tbody id='XTNkS'></tbody>
          1. <tfoot id='XTNkS'></tfoot>

              <legend id='XTNkS'><style id='XTNkS'><dir id='XTNkS'><q id='XTNkS'></q></dir></style></legend>

              • <small id='XTNkS'></small><noframes id='XTNkS'>

                本文介紹了App_LocalResources 如何與 MVC 一起工作?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                問題描述

                我一直在研究我的第一個 MVC 應用程序,我想對它進行本地化.我知道如何使用 App_GlobalResources,但我更喜歡使用 App_LocalResources.

                I've been working through my first MVC application, and I'd like to localize it. I know how to use the App_GlobalResources but I'd prefer to use the App_LocalResources.

                在典型的 WebForms 應用程序中,您將 App_LocalResources 文件夾與 ASPX 文件放在同一目錄中……這在 MVC 中是否相同(IE:我是否將它們放在views"目錄中的相應子文件夾中)?

                In a typical WebForms application, you put the App_LocalResources folder in the same directory as the ASPX file... is this the same in MVC (IE: do I put them in the respective subfolders in the "views" directory)?

                另外,在您的視圖中訪問 App_GlobalResources 時,您可以這樣做 <%=Html.Encode(Resources.Index.Title)%> 但是我無法使用 App_LocalResources.我不想讓我的 <label runat="server" 來利用 meta:resourcekey

                Also, when accessing the App_GlobalResources in your view you can do it like so <%=Html.Encode(Resources.Index.Title)%> however I cannot do that with the App_LocalResources. I don't want to have to make my <label runat="server" in order to take advantage of the meta:resourcekey

                我發(fā)現(xiàn)了一種方法來做到這一點,但我不確定這是否是最好的方法.思路是這樣的

                I discovered ONE method to do this, but I'm not sure if this is the best method. Here's the idea

                1. 您將 App_LocalResources 文件夾作為子文件夾放在各自的 View 文件夾中
                2. 您創(chuàng)建與您的視圖相對應的 resx 文件... IE:Index.resxAbout.resx
                3. 您將 Resx 文件屬性設置為Public"(PublicResXFileCodeGenerator)、Embeded Resource"、Views.[viewname]"命名空間
                4. 創(chuàng)建一個名為Title"的新資源名稱,并將您想要的任何內(nèi)容放入 Value 中.
                1. You put the App_LocalResources folder as a sub folder within your respective View folder
                2. You create resx files that correspond to your Views... IE: Index.resx or About.resx
                3. You set the Resx files properties to be "Public" (PublicResXFileCodeGenerator), "Embeded Resource", "Views.[viewname]" namespace
                4. Create a new resource name called "Title" and put whatever you want in the Value.

                現(xiàn)在我可以使用類似這樣的方式引用本地資源

                Now I can reference the Local Resources using something like this

                <%= MyProj.Views.Home.Index.Title%>

                我看到的唯一問題是資源是嵌入的,如果不重新編譯項目,我無法添加新的語言環(huán)境.

                The only problem I see with this is the fact that the resources are embedded and I cannot add new locales without re-compiling the project.

                這是我對這種方法的參考.

                推薦答案

                不應將 App_GlobalResources 或 App_LocalResources 與 MVC 一起使用.這是因為這些資源的工作方式.這些資源沒有嵌入到您的項目中,而是由 ASP.NET 運行時編譯.這意味著當不在 ASP.NET 運行時中運行時,您的資源將不可用,這意味著如果您使用其中的資源,您將失去對視圖和控制器進行單元測試的能力.

                You should not use App_GlobalResources or App_LocalResources with MVC. That is because of the way these resources work. These resources are not embedded in your project, but are instead compiled by the ASP.NET runtime. This means that your resources will not be available when not running inside the ASP.NET runtime, which means you would lose the ability to unit test your views and controllers if you use resources in them.

                這篇文章提供了更多關于它的細節(jié).

                This post gives more details about it.

                相反,您應該使用您在問題中提到的方法.將您的資源放在您想要的任何位置,并將其設置為嵌入式資源",自定義工具應為PublicResXFileCodeGenerator".

                Instead, you should use the approach you mention yourself in your question. Put your resource whereever you want, and set it to 'Embedded resource' and the custom tool should be 'PublicResXFileCodeGenerator'.

                這篇關于App_LocalResources 如何與 MVC 一起工作?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

                【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請聯(lián)系我們刪除處理,感謝您的支持!

                相關文檔推薦

                Ignore whitespace while reading XML(讀取 XML 時忽略空格)
                extracting just page text using HTMLAgilityPack(使用 HTMLAgilityPack 僅提取頁面文本)
                C# extracting data from XML(C# 從 XML 中提取數(shù)據(jù))
                Read a XML (from a string) and get some fields - Problems reading XML(讀取 XML(從字符串)并獲取一些字段 - 讀取 XML 時出現(xiàn)問題)
                Reading large XML documents in .net(在 .net 中讀取大型 XML 文檔)
                How to create folder in Google Drive using .NET API?(如何使用 .NET API 在 Google Drive 中創(chuàng)建文件夾?)

                <small id='KsWq3'></small><noframes id='KsWq3'>

                <legend id='KsWq3'><style id='KsWq3'><dir id='KsWq3'><q id='KsWq3'></q></dir></style></legend>

                      <i id='KsWq3'><tr id='KsWq3'><dt id='KsWq3'><q id='KsWq3'><span id='KsWq3'><b id='KsWq3'><form id='KsWq3'><ins id='KsWq3'></ins><ul id='KsWq3'></ul><sub id='KsWq3'></sub></form><legend id='KsWq3'></legend><bdo id='KsWq3'><pre id='KsWq3'><center id='KsWq3'></center></pre></bdo></b><th id='KsWq3'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='KsWq3'><tfoot id='KsWq3'></tfoot><dl id='KsWq3'><fieldset id='KsWq3'></fieldset></dl></div>

                      <tfoot id='KsWq3'></tfoot>
                        <tbody id='KsWq3'></tbody>
                      • <bdo id='KsWq3'></bdo><ul id='KsWq3'></ul>

                        1. 主站蜘蛛池模板: 久久久91精品国产一区二区精品 | 一区二区三区四区日韩 | 黄网站免费入口 | 久久99精品久久久久蜜桃tv | 欧美日韩一区二区三区四区 | 亚洲一区视频在线 | 久久久久国产精品 | 中文字幕高清视频 | 亚洲精品一区中文字幕 | 欧美1区 | 国产在线中文字幕 | 欧美国产亚洲一区二区 | 国产电影一区二区在线观看 | 欧美激情一区二区三级高清视频 | 中文字幕一区在线 | 国产夜恋视频在线观看 | 天天影视色综合 | 免费看a| 91欧美精品| 国产精品视频网 | 欧美在线资源 | 在线一区视频 | 69性欧美高清影院 | 国产日韩视频 | 麻豆av在线免费观看 | 人人澡人人射 | 久久精品国产亚洲 | 国产成人一区二区三区 | 人人人人爽 | 婷婷综合| 91玖玖| 日本成人免费网站 | 黄色永久免费 | 国产精品成人久久久久 | 欧美中文字幕一区 | 91精品国产自产精品男人的天堂 | 久久久精品一区二区三区 | 一区二区高清 | 色综合久久天天综合网 | 亚洲va国产日韩欧美精品色婷婷 | re久久|