为了创建一个OData the服务,我已经在http://www.asp.net/web-api/overview/odata-support-in-aspnet-web-api上学习了一些教程。
我的服务设置如下:
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请求,然后webservice就会按预期运行。
当我尝试使用batch端点时,得到的结果是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
。
我试图更新到夜间构建,但这不起作用(不知道是否有人能告诉我如何让它工作?)
我认为我只需要等待一个新的构建版本发布,这是正确的吗?
发布于 2013-06-20 15:34:40
Tom,您可以尝试以下操作,看看它是否解决了您升级到夜间构建的问题:
使用post中提到的命令卸载package.
不能将ASystem.Web.WebPages.Razor.Configuration.HostSection转换为BSystem.Web.WebPages.Razor.Configuration.HostSection.类型A源自位于位置'C:\windows\Microsoft.Net\assembly\GAC_MSIL\System.Web.WebPages.Razor\v4.0_2.0.0.0__31bf3856ad364e35\System.Web.WebPages.Razor.dll'.的上下文'Default‘中的'System.Web.WebPages.Razor,Version=2.0.0.0,Culture=neutral,PublicKeyToken=31bf3856ad364e35类型B源自位于location 'C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary Files\root\cae46085\829a2d25\assembly\dl3\f12eaaeb\d73d086c_ca6dce01\System.Web.WebPages.Razor.dll'.
现在,<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>
https://stackoverflow.com/questions/17211914
复制