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

      <bdo id='GYX7G'></bdo><ul id='GYX7G'></ul>

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

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

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

        在 ASP.NET MVC 中設置默認 JSON 序列化程序

        Setting the default JSON serializer in ASP.NET MVC(在 ASP.NET MVC 中設置默認 JSON 序列化程序)
              <bdo id='aG5Q7'></bdo><ul id='aG5Q7'></ul>

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

                  <legend id='aG5Q7'><style id='aG5Q7'><dir id='aG5Q7'><q id='aG5Q7'></q></dir></style></legend>
                  <tfoot id='aG5Q7'></tfoot>
                    <tbody id='aG5Q7'></tbody>
                  <i id='aG5Q7'><tr id='aG5Q7'><dt id='aG5Q7'><q id='aG5Q7'><span id='aG5Q7'><b id='aG5Q7'><form id='aG5Q7'><ins id='aG5Q7'></ins><ul id='aG5Q7'></ul><sub id='aG5Q7'></sub></form><legend id='aG5Q7'></legend><bdo id='aG5Q7'><pre id='aG5Q7'><center id='aG5Q7'></center></pre></bdo></b><th id='aG5Q7'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='aG5Q7'><tfoot id='aG5Q7'></tfoot><dl id='aG5Q7'><fieldset id='aG5Q7'></fieldset></dl></div>
                  本文介紹了在 ASP.NET MVC 中設置默認 JSON 序列化程序的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  我正在開發一個已部分轉換為 MVC 的現有應用程序.每當控制器以 JSON ActionResult 響應時,枚舉都會作為數字而不是字符串名稱發送.聽起來默認的序列化程序應該是 JSON.Net,它應該將枚舉作為它們的名稱發送過來,而不是整數表示,但這里不是這種情況.

                  I'm working on an existing application that has been partially converted over to MVC. Whenever a controller responds with a JSON ActionResult, the enums are sent as numbers opposed to the string name. It sounds like the default serializer should be JSON.Net, which should be sending the enums over as their names opposed to the integer representation, but that's not the case here.

                  我是否缺少將其設置為默認序列化程序的 web.config 設置?還是有其他需要更改的設置?

                  Am I missing a web.config setting that sets this as the default serializer? Or is there another setting that needs to be changed?

                  推薦答案

                  在 ASP.Net MVC4 中,JsonResult 類中使用的默認 JavaScript 序列化器仍然是 JavaScriptSerializer (你可以在 代碼)

                  In ASP.Net MVC4 the default JavaScript serializer which is used in the JsonResult class is still the JavaScriptSerializer (you can check it in the code)

                  我認為您將它與 ASP.Net Web.API 混淆了,其中 JSON.Net 是默認的 JS 序列化程序,但 MVC4 不使用它.

                  I think you have confused it with the ASP.Net Web.API where JSON.Net is the default JS serializer but MVC4 doesn't use it.

                  所以你需要配置 JSON.Net 以使用 MVC4(基本上你需要創建自己的 JsonNetResult),關于它的文章很多:

                  So you need to configure JSON.Net to work with MVC4 (basically you need to create your own JsonNetResult), there are plenty of articles about it:

                  • ASP.NET MVC和 Json.NET
                  • 使用 JSON.NET 作為 ASP.NET MVC 3 中的默認 JSON 序列化程序 - 可能嗎?

                  如果您還想將 JSON.Net 用于控制器操作參數,那么在模型綁定期間,您需要編寫自己的 ValueProviderFactory 實現.

                  If you also want to use JSON.Net for controller action parameters so during the model binding then you need write your own ValueProviderFactory implementation.

                  你需要注冊你的實現:

                  ValueProviderFactories.Factories
                      .Remove(ValueProviderFactories.Factories
                                                    .OfType<JsonValueProviderFactory>().Single());
                  ValueProviderFactories.Factories.Add(new MyJsonValueProviderFactory());
                  

                  您可以使用內置的 JsonValueProviderFactory 作為示例或這篇文章:ASP.NET MVC 3 – 使用 Json.Net 改進的 JsonValueProviderFactory

                  You can use the built in JsonValueProviderFactory as an example or this article: ASP.NET MVC 3 – Improved JsonValueProviderFactory using Json.Net

                  這篇關于在 ASP.NET MVC 中設置默認 JSON 序列化程序的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

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

                  相關文檔推薦

                  Ignore whitespace while reading XML(讀取 XML 時忽略空格)
                  XML to LINQ with Checking Null Elements(帶有檢查空元素的 XML 到 LINQ)
                  Reading XML with unclosed tags in C#(在 C# 中讀取帶有未閉合標簽的 XML)
                  Parsing tables, cells with Html agility in C#(在 C# 中使用 Html 敏捷性解析表格、單元格)
                  delete element from xml using LINQ(使用 LINQ 從 xml 中刪除元素)
                  Parse malformed XML(解析格式錯誤的 XML)
                1. <i id='bRBqU'><tr id='bRBqU'><dt id='bRBqU'><q id='bRBqU'><span id='bRBqU'><b id='bRBqU'><form id='bRBqU'><ins id='bRBqU'></ins><ul id='bRBqU'></ul><sub id='bRBqU'></sub></form><legend id='bRBqU'></legend><bdo id='bRBqU'><pre id='bRBqU'><center id='bRBqU'></center></pre></bdo></b><th id='bRBqU'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='bRBqU'><tfoot id='bRBqU'></tfoot><dl id='bRBqU'><fieldset id='bRBqU'></fieldset></dl></div>

                  <tfoot id='bRBqU'></tfoot>

                    <legend id='bRBqU'><style id='bRBqU'><dir id='bRBqU'><q id='bRBqU'></q></dir></style></legend>
                        <tbody id='bRBqU'></tbody>

                            <bdo id='bRBqU'></bdo><ul id='bRBqU'></ul>

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

                            主站蜘蛛池模板: 免费久草| 成年女人免费v片 | 国产免国产免费 | 全免一级毛片 | 免费午夜视频在线观看 | 欧美日韩a| 日韩精品1区2区3区 国产精品国产成人国产三级 | 国产99视频精品免费播放照片 | 国产高清久久久 | 尤物在线| 毛色毛片免费看 | 伊色综合久久之综合久久 | 亚洲高清免费视频 | 天天干天天插天天 | 欧美精品网 | 夜夜av| 免费中文字幕 | 国产精品久久久久久久岛一牛影视 | 国产婷婷精品av在线 | 狠狠操电影| 亚洲国产精品久久人人爱 | 国产视频1区 | 在线播放中文字幕 | 久久91av | 国产一区二区 | 国产精品久久久久无码av | 国产免费一区二区三区 | 免费在线看黄 | 亚洲电影一区二区三区 | 亚洲免费网址 | 精品二区| 精品久久久av | 日韩在线欧美 | 日韩电影中文字幕 | 久在线视频 | 国产午夜精品一区二区三区四区 | 欧洲毛片| 欧美成人a∨高清免费观看 色999日韩 | 亚洲免费观看视频网站 | 午夜精品久久久久久久 | 在线观看中文字幕视频 |