遇到标题中所说的问题原因是使用 jQuery AJAX 以 POST 方式调用 Asp.Net Web API 。解决办法请看以下代码中有注释的部分。

public static class WebApiConfig
{
public static void Register(HttpConfiguration config)
{
config.Formatters.Clear();
config.Formatters.Add( new JsonMediaTypeFormatter {
SerializerSettings = {
ContractResolver = new DefaultContractResolver()
}
} ); // 添加以下语句即可解决问题
config.Formatters.Add( new JQueryMvcFormUrlEncodedFormatter() );
}
}

"Asp.Net Web Api MediaTypeFormatter Error for x-www-formurlencoded data" 解决方法的更多相关文章

  1. ASP.NET Web API 记录请求响应数据到日志的一个方法

    原文:http://blog.bossma.cn/dotnet/asp-net-web-api-log-request-response/ ASP.NET Web API 记录请求响应数据到日志的一个 ...

  2. ASP.NET Web API 应用教程(一) ——数据流使用

    相信已经有很多文章来介绍ASP.Net Web API 技术,本系列文章主要介绍如何使用数据流,HTTPS,以及可扩展的Web API 方面的技术,系列文章主要有三篇内容. 主要内容如下: I  数据 ...

  3. ASP.NET Web API 2中的错误处理

    前几天在webapi项目中遇到一个问题:Controller构造函数中抛出异常时全局过滤器捕获不到,于是网搜一把写下这篇博客作为总结. HttpResponseException 通常在WebAPI的 ...

  4. ASP.NET Web API实践系列09,在Fiddler和控制台中模拟GET和POST请求

    ASP.NET Web API本质是由一个进程托管的一组类,需要宿主,这个宿主可以是ASP.NET应用程序,可以是MVC项目,可以是控制台应用程序,也可以是自己定制的宿主. 在VS2012中创建一个& ...

  5. Professional C# 6 and .NET Core 1.0 - Chapter 42 ASP.NET Web API

    本文内容为转载,重新排版以供学习研究.如有侵权,请联系作者删除. 转载请注明本文出处: -------------------------------------------------------- ...

  6. Handling HTTP 404 Error in ASP.NET Web API

            Introduction: Building modern HTTP/RESTful/RPC services has become very easy with the new AS ...

  7. Global Error Handling in ASP.NET Web API 2(webapi2 中的全局异常处理)

    目前,在Web API中没有简单的方法来记录或处理全局异常(webapi1中).一些未处理的异常可以通过exception filters进行处理,但是有许多情况exception filters无法 ...

  8. ASP.NET Web API Model-ParameterBinding

    ASP.NET Web API Model-ParameterBinding 前言 通过上个篇幅的学习了解Model绑定的基础知识,然而在ASP.NET Web API中Model绑定功能模块并不是被 ...

  9. 【ASP.NET Web API教程】6.3 内容协商

    本文是Web API系列教程的第6.3小节 6.3 Content Negotiation 6.3 内容协商 摘自:http://www.asp.net/web-api/overview/format ...

随机推荐

  1. CodeBlocks 中fopen函数不支持命令 “r”

    //codeblocks #include<stdio.h> #include<stdlib.h> void main(void) { FILE *fp=NULL; if((f ...

  2. 552 you must authentication

    配置邮箱到outlook时 出现以下错误: 发送测试电子邮件消息: 无法发送此邮件.请在帐户属性中验证电子邮件地址.  响应服务器: 552 you must authentication 需要在”其 ...

  3. document的一点点

    var str = "hello world" document.write(str.length)输出字符串长度   12 给string 添加样式 <p>Big: ...

  4. 论文笔记之:Generative Adversarial Text to Image Synthesis

    Generative Adversarial Text to Image Synthesis ICML 2016  摘要:本文将文本和图像练习起来,根据文本生成图像,结合 CNN 和 GAN 来有效的 ...

  5. Docker run命令详解 转

    1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 Usage: doc ...

  6. 【转】vc++MCF/C++/C中怎样让应用程序获得或以管理员权限运行 ,ShellExecuteEX编程 --- 获取管理员权限

    ShellExecuteEX编程 --- 获取管理员权限:http://blog.csdn.net/jhui163/article/details/5873027 怎样让你的应用程序获得管理员权限:就 ...

  7. 使用yield关键字来提高性能

    比如我们在开发当中往往会遇到这样的问题: public List<string> FindBobs(string [] names)   { List<string> bobs ...

  8. [solr] - Facet - autocomplete

    Solr的facet可以用于一般性的前缀式自动完成功能,当然,它的主要功能是用于做统计.分类.区间等. 统计.分类.区间功能,可参考下文: http://hongweiyi.com/2013/03/a ...

  9. 单例模式中的多线程分析synchronized

    谈到单例模式,我们立马会想到饿汉式和懒汉式加载,所谓饿汉式就是在创建类时就创建好了实例,懒汉式在获取实例时才去创建实例,即延迟加载. 饿汉式: 1 package com.bijian.study; ...

  10. [Tex学习笔记]写文章需要规范、需要引用到位. [LaTeX代码]

    \documentclass{ctexart} \usepackage{CJK,amsmath,amssymb,amsthm} \begin{document} 写文章需要规范.需要引用到位. 方程: ...