在我的WEB API OData v4中添加DefaultODataBatchHandler后出现错误。
DefaultODataBatchHandler defaultODataBatchHandler = new DefaultODataBatchHandler(GlobalConfiguration.DefaultServer);
在浏览器中,我收到此错误:批处理请求必须具有“ Content-Type”标头。 在POSTMan中,我遇到以下错误:批处理请求的媒体类型必须为'multipart / mixed'。
如果我没有在上面放置代码。访问 $ batch
时出现此错误"Message": "No HTTP resource was found that matches the request URI 'http://localhost:2288/$batch'.",
"MessageDetail": "No route providing a controller name was found to match request URI 'http://localhost:2288/$batch'"
RouteConfig.cs
public class RouteConfig
{
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
);
}
}
答案 0 :(得分:0)
现在就搞定。
我只需要添加CORS
var cors = new EnableCorsAttribute(
"*",
"*",
"*",
"*"
);
config.EnableCors(cors);
然后将通配符用作公开的标题。