asp.net-core - OData 分组实体
问题描述
我正在尝试使用以下网址
v1/$metadata
v1/se/companies
v1/se/addresses
v1/no/companies
v1/no/addresses
但是如果我使用[ODataRoutePrefix("se/Companies")]
我会收到以下错误
System.InvalidOperationException: The path template 'se/Companies({companyNumber})' on the action 'Get' in controller 'SwedishCompany' is not a valid OData path template. Resource not found for the segment 'se'.
at Microsoft.AspNet.OData.Routing.Conventions.AttributeRoutingConvention.GetODataPathTemplate(String prefix, String pathTemplate, IServiceProvider requestContainer, String controllerName, String actionName)
at Microsoft.AspNet.OData.Routing.Conventions.AttributeRoutingConvention.<>c__DisplayClass11_0.<GetODataPathTemplates>b__1(ODataRouteAttribute route)
at System.Linq.Enumerable.WhereSelectArrayIterator`2.MoveNext()
at System.Linq.Enumerable.WhereEnumerableIterator`1.MoveNext()
at Microsoft.AspNet.OData.Routing.Conventions.AttributeRoutingConvention.BuildAttributeMappings(IEnumerable`1 controllerActions)
at Microsoft.AspNet.OData.Routing.Conventions.AttributeRoutingConvention.get_AttributeMappings()
at Microsoft.AspNet.OData.Routing.Conventions.AttributeRoutingConvention.SelectAction(RouteContext routeContext)
at Microsoft.AspNet.OData.Routing.ODataActionSelector.SelectCandidates(RouteContext context)
at Microsoft.AspNetCore.Mvc.Internal.MvcRouteHandler.RouteAsync(RouteContext context)
at Microsoft.AspNetCore.Routing.Route.OnRouteMatched(RouteContext context)
at Microsoft.AspNetCore.Routing.RouteBase.RouteAsync(RouteContext context)
at Microsoft.AspNetCore.Routing.RouteCollection.RouteAsync(RouteContext context)
at Microsoft.AspNetCore.Builder.RouterMiddleware.Invoke(HttpContext httpContext)
at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpProtocol.ProcessRequests[TContext](IHttpApplication`1 application)
有什么方法可以添加前缀/
吗?
解决方案
推荐阅读
- javascript - 更改文本背景荧光笔
- suitescript - SuiteScript 加载保存的搜索并添加过滤器会引发错误
- linux - 一次重启多个服务的Shell脚本
- php - 如何访问 htdocs 文件夹之外的 XAMPP mysql 数据库
- java - Java根据属性对对象进行排序
- java - 转换为 JSON 时的堆栈溢出问题
- rust - 使用 Tokio 启动多个线程
- android - Kotlin - IllegalArgumentException:指定为非空的参数为空
- node.js - 如何使用 socket.io 库区分客户端 TCP 套接字和客户端 websocket?
- android - 如何在 Android Studio 3.3 canary 13 中使用 MapView?