久久久久久久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 中設(shè)置默認 JSON 序列化程序

        Setting the default JSON serializer in ASP.NET MVC(在 ASP.NET MVC 中設(shè)置默認 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 中設(shè)置默認 JSON 序列化程序的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

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

                  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.

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

                  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(基本上你需要創(chuàng)建自己的 JsonNetResult),關(guān)于它的文章很多:

                  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 用于控制器操作參數(shù),那么在模型綁定期間,您需要編寫自己的 ValueProviderFactory 實現(xiàn).

                  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.

                  你需要注冊你的實現(xiàn):

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

                  您可以使用內(nèi)置的 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

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

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

                  相關(guān)文檔推薦

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

                            主站蜘蛛池模板: 中文字幕精品视频 | 91五月天 | 人人爽人人爽人人 | 91在线看片 | 日本熟妇毛耸耸xxxxxx | 新av在线 | 国产91av视频 | 91亚洲一区 | 成人高清视频在线观看 | 国产精品久久网 | 欧美在线a | 亚洲综合自拍 | 黄视频网站在线观看 | 亚洲视频精品 | 亚洲欧美网站 | 国产玖玖| 亚洲美女一区 | 成人精品一区二区三区 | 亚洲精品tv | 日韩毛片网站 | 黄色一级大片在线免费看国产一 | 一区二区三区在线播放 | 国产精品国产三级国产专区52 | 日韩免费| 免费观看黄色片 | 黄色国产网站 | 一区二区三区视频 | 99黄色 | 免费看黄色小视频 | 精品自拍视频 | 日韩毛片在线观看 | 四虎在线免费观看 | 精品蜜桃一区二区三区 | 成人激情视频在线观看 | 黄色大片网站 | 中文字幕影院 | 99超碰在线观看 | 国产欧美日韩在线观看 | 亚洲成a人 | 91欧美日韩 | 天天干少妇|