2013-06-20 166 views
1

我一直在浏览教程 http://www.asp.net/web-api/overview/odata-support-in-aspnet-web-api 以创建OData Web服务。如何创建批处理端点用于asp.net OData web服务

我有我的服务设置如下:

var modelBuilder = new ODataConventionModelBuilder(); 

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

var edmModel = modelBuilder.GetEdmModel(); 

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

我可以发出GET请求来http://localhost:49255/odata/Analytics那么web服务功能如预期。

当我尝试使用批处理端点我得到一个404,我张贴到

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

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

DefaultODataBatchHandler似乎并不存在。实际上System.Web.Http.OData.Batch似乎并不存在。我正在使用Microsoft.AspNet.WebApi.OData version 4.0.30506

我尝试更新在每晚构建但这并没有工作(不知道如果有人能告诉我怎样才能得到这个工作?)

nu-get error message

我是正确的思维我只需要等待新版本发布?

回答

2

汤姆,你可以尝试以下,看它是否解决了升级您的问题以每晚构建:

  • 卸载“Microsoft.AspNet.Mvc.FixedDisplayModes”包。

  • 使用您在后文中提到的命令升级OData软件包。

  • 当你启动应用程序,你可能会看到以下错误:

    [A] System.Web.WebPages.Razor.Configuration.HostSection不能转换为[B] System.Web.WebPages。 Razor.Configuration.HostSection。类型A来源于位于'C:\ windows \ Microsoft.Net \ assembly \ GAC_MSIL \ System'上下文'Default'中的'System.Web.WebPages.Razor,Version = 2.0.0.0,Culture = neutral,PublicKeyToken = 31bf3856ad364e35' .Web.WebPages.Razor \ v4.0_2.0.0.0__31bf3856ad364e35 \ System.Web.WebPages.Razor.dll”。类型B来源于位于'C:\ Windows \ Microsoft.NET \ Framework \ v4.0.30319'上下文'Default'中的'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'。

  • 要解决上述错误,修改装配在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>

  • 你应该能成功现在启动应用程序。