如何创建/批处理终结点在asp.net OData Web服务的位置 [英] How to create / where the batch endpoint is for an asp.net OData webservice

查看:78
本文介绍了如何创建/批处理终结点在asp.net OData Web服务的位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在浏览以下教程 http://www.asp.net/web-api/overview/odata-support-in-aspnet-web-api 创建一个OData Web服务.

I have been going through the tutorials at http://www.asp.net/web-api/overview/odata-support-in-aspnet-web-api to create an OData webservice.

我的服务设置如下:

var modelBuilder = new ODataConventionModelBuilder();

modelBuilder.EntitySet<Analytic>("Analytics");

var edmModel = modelBuilder.GetEdmModel();

config.Routes.MapODataRoute(
   routeName: "Odata",
   routePrefix: "odata",
   model: edmModel);

我可以向 http://localhost:49255/odata/Analytics 发出get请求,然后Web服务将按预期运行.

I can issue a get request to http://localhost:49255/odata/Analytics then the webservice functions as expected.

当我尝试使用批处理终结点时,我得到了404.我要发布到

When I try and use the batch endpoint I am getting a 404. I am posting to

http://localhost:49255/odata/$batch

如此处所示. http://www.odata.org/documentation/odata-v2-documentation/batch-processing/

我找到了以下页面 https://aspnetwebstack.codeplex.com/wikipage?title = Web%20API%20Request%20Batching ,这表明我需要明确地设置BatchHandler

I found the following page https://aspnetwebstack.codeplex.com/wikipage?title=Web%20API%20Request%20Batching which suggests that I need to explicity be setting the BatchHandler

config.Routes.MapODataRoute(
                routeName: "defaultOdata",
                routePrefix: "odata",
                model: GetModel(),
                batchHandler: new DefaultODataBatchHandler(GlobalConfiguration.DefaultServer));

但是 DefaultODataBatchHandler 似乎不存在.实际上, System.Web.Http.OData.Batch 似乎根本不存在.我正在使用 Microsoft.AspNet.WebApi.OData版本4.0.30506 .

But DefaultODataBatchHandler doesn't seem to exist. In fact System.Web.Http.OData.Batch doesn't seem to exist at all. I am using Microsoft.AspNet.WebApi.OData version 4.0.30506.

我尝试更新到每晚构建,但这没有用(不知道是否有人可以告诉我如何使它工作?)

I tried to update to the nightly build but this didn't work (don't know if anyone can tell me how I can get this working?)

我是否正确地认为我只需要等待更新的版本发布?

Am I right in thinking that I just need to wait for a newer build to be released?

推荐答案

Tom,您可以尝试以下方法来查看它是否解决了升级到夜间版本的问题:

Tom, you can try the following to see if it resolves your issue of upgrading to nightly builds:

  • 卸载"Microsoft.AspNet.Mvc.FixedDisplayModes"程序包.

  • Uninstall "Microsoft.AspNet.Mvc.FixedDisplayModes" package.

使用本文中提到的命令升级OData软件包.

Upgrade the OData package using your command mentioned in the post.

启动应用程序时,您可能会看到以下错误:

When you launch the application, you would probably see the following error:

[A] System.Web.WebPages.Razor.Configuration.HostSection无法转换为[B] System.Web.WebPages.Razor.Configuration.HostSection.类型A源自'System.Web.WebPages.Razor,Version = 2.0.0.0,Culture = neutral,PublicKeyToken = 31bf3856ad364e35'在上下文'Default'中的位置'C:\ windows \ Microsoft.Net \ assembly \ GAC_MSIL \ System.Web.WebPages.Razor \ v4.0_2.0.0.0__31bf3856ad364e35 \ System.Web.WebPages.Razor.dll'.类型B源自位置'C:\ Windows \ Microsoft.NET \ Framework \ v4.0.30319的上下文'默认'中的'System.Web.WebPages.Razor,Version = 3.0.0.0,Culture = neutral,PublicKeyToken = 31bf3856ad364e35'\ Temporary ASP.NET Files \ root \ cae46085 \ 829a2d25 \ assembly \ dl3 \ f12eaaeb \ d73d086c_ca6dce01 \ System.Web.WebPages.Razor.dll'.

[A]System.Web.WebPages.Razor.Configuration.HostSection cannot be cast to [B]System.Web.WebPages.Razor.Configuration.HostSection. Type A originates from 'System.Web.WebPages.Razor, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' in the context 'Default' at location 'C:\windows\Microsoft.Net\assembly\GAC_MSIL\System.Web.WebPages.Razor\v4.0_2.0.0.0__31bf3856ad364e35\System.Web.WebPages.Razor.dll'. Type B originates from 'System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' in the context 'Default' at location 'C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\cae46085\829a2d25\assembly\dl3\f12eaaeb\d73d086c_ca6dce01\System.Web.WebPages.Razor.dll'.

要解决以上错误,请将Web.config中的程序集绑定修改为以下内容:
< assemblyBinding xmlns ="urn:schemas-microsoft-com:asm.v1" xmlns:bcl ="urn:schemas-microsoft-com:bcl">< dependentAssembly>< assemblyIdentity name ="System.Web.Helpers" publicKeyToken ="31bf3856ad364e35"/>< bindingRedirect oldVersion ="1.0.0.0-3.0.0.0" newVersion ="3.0.0.0"/></dependentAssembly>< dependentAssembly>< assemblyIdentity name ="System.Web.WebPages.Razor" publicKeyToken ="31bf3856ad364e35"/>< bindingRedirect oldVersion ="1.0.0.0-3.0.0.0" newVersion ="3.0.0.0"/></dependentAssembly>< dependentAssembly>< assemblyIdentity name ="System.Web.Mvc" publicKeyToken ="31bf3856ad364e35"/>< bindingRedirect oldVersion ="1.0.0.0-5.0.0.0" newVersion ="5.0.0.0"/></dependentAssembly>< dependentAssembly>< assemblyIdentity name ="System.Web.WebPages" publicKeyToken ="31bf3856ad364e35"/>< bindingRedirect oldVersion ="1.0.0.0-3.0.0.0" newVersion ="3.0.0.0"/></dependentAssembly>< dependentAssembly>< assemblyIdentity name ="EntityFramework" publicKeyToken ="b77a5c561934e089"/>< bindingRedirect oldVersion ="0.0.0.0-5.0.0.0" newVersion ="5.0.0.0"/></dependentAssembly>< dependentAssembly>< assemblyIdentity name ="WebGrease" publicKeyToken ="31bf3856ad364e35"/>< bindingRedirect oldVersion ="1.0.0.0-1.3.0.0" newVersion ="1.3.0.0"/></dependentAssembly></assemblyBinding>

To fix the above error, modify the assembly binding in Web.config to below:
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1" xmlns:bcl="urn:schemas-microsoft-com:bcl"> <dependentAssembly> <assemblyIdentity name="System.Web.Helpers" publicKeyToken="31bf3856ad364e35" /> <bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" /> </dependentAssembly> <dependentAssembly> <assemblyIdentity name="System.Web.WebPages.Razor" publicKeyToken="31bf3856ad364e35" /> <bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" /> </dependentAssembly> <dependentAssembly> <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" /> <bindingRedirect oldVersion="1.0.0.0-5.0.0.0" newVersion="5.0.0.0" /> </dependentAssembly> <dependentAssembly> <assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35" /> <bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" /> </dependentAssembly> <dependentAssembly> <assemblyIdentity name="EntityFramework" publicKeyToken="b77a5c561934e089" /> <bindingRedirect oldVersion="0.0.0.0-5.0.0.0" newVersion="5.0.0.0" /> </dependentAssembly> <dependentAssembly> <assemblyIdentity name="WebGrease" publicKeyToken="31bf3856ad364e35" /> <bindingRedirect oldVersion="1.0.0.0-1.3.0.0" newVersion="1.3.0.0" /> </dependentAssembly> </assemblyBinding>

您现在应该能够成功启动该应用程序.

Your should be able to launch the application successfully now.

这篇关于如何创建/批处理终结点在asp.net OData Web服务的位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆