【发布时间】:2015-07-13 09:41:19
【问题描述】:
我是 ASP.NET MVC web api 的新手。我正在尝试运行由 Visual Studio 2013 创建的默认 web api 项目。另外,我正在使用 fiddler 来测试 web api。
在该默认项目中,创建了一个发布方法“api/Account/Register”。当我尝试在提琴手中运行它时,会发生 UnsupportedMediaTypeException。我搜索了很多并尝试添加内容类型 content-type: application/json;提琴手的作曲家部分的标题。但异常仍然发生。以下是完整的异常细节 -
{"Message":"请求包含实体主体,但没有 Content-Type 标头。此资源不支持推断的媒体类型 'application/octet-stream'。","ExceptionMessage":"没有 MediaTypeFormatter可用于从媒体类型为“application/octet-stream”的内容中读取“RegisterBindingModel”类型的对象。","ExceptionType":"System.Net.Http.UnsupportedMediaTypeException","StackTrace":" at System.Net.Http .HttpContentExtensions.ReadAsAsync[T](HttpContent content, Type type, IEnumerable1 formatters, IFormatterLogger formatterLogger, CancellationToken cancellationToken)\r\n at System.Net.Http.HttpContentExtensions.ReadAsAsync(HttpContent content, Type type, IEnumerable1 formatters, IFormatterLogger formatterLogger, CancellationToken cancelToken)\r\n at System.Web.Http.ModelBinding.FormatterParameterBinding.ReadContentAsync(HttpRequestMessage request, Type type, IEnumerable`1 formatters, IFormatterLogger formatterLogger, CancellationToken cancelToken)"}
这是我在提琴手中的设置 -
请让我知道我缺少什么。
【问题讨论】:
标签: asp.net-mvc post asp.net-web-api fiddler