久久久久久久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

                我發現了一種方法來做到這一點,但我不確定這是否是最好的方法.思路是這樣的

                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. 您創建與您的視圖相對應的 resx 文件... IE:Index.resxAbout.resx
                3. 您將 Resx 文件屬性設置為Public"(PublicResXFileCodeGenerator)、Embeded Resource"、Views.[viewname]"命名空間
                4. 創建一個名為Title"的新資源名稱,并將您想要的任何內容放入 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.

                現在我可以使用類似這樣的方式引用本地資源

                Now I can reference the Local Resources using something like this

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

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

                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.

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

                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模板網!

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

                相關文檔推薦

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

                <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. 主站蜘蛛池模板: va在线| 精品视频在线一区 | 欧美国产视频 | 一级黄色生活视频 | 色黄视频在线 | 91精品国产91久久久久久最新 | 久久精品日产第一区二区三区 | 欧美又大粗又爽又黄大片视频 | 一区不卡在线观看 | 天堂一区二区三区四区 | 三级在线视频 | 国产免费国产 | 一本一道久久a久久精品综合 | 激情毛片 | 日本久久久久久 | 国产精品不卡一区 | 国产日韩欧美激情 | 欧美日本免费 | 欧美日韩不卡合集视频 | 日本成人三级电影 | 日韩免费在线视频 | 欧美黑人一区二区三区 | 自拍偷拍亚洲一区 | 国产成人久久精品 | 国产一区不卡 | 免费毛片在线 | 久久精品久久精品久久精品 | 国产一区二区精华 | 在线亚洲电影 | 国产精品视频在线免费观看 | 欧美日韩中文字幕在线 | 中文字幕在线观看一区二区 | 成人三级电影 | www日本在线| 日韩av.com | 久久精品成人 | 国产一区二区在线免费观看 | 欧美成人在线网站 | 午夜激情小视频 | 亚洲va在线va天堂va狼色在线 | 91久久看片 |