Closed seamusic closed 3 years ago
组件暂不支持多个Route标签,可以尝试使用组件的Url重写功能
mApiServer.UrlRewrite.Add("/api/PostStream/{code}/{datacode}", "/api/PostStream");
mApiServer.UrlRewrite.Add("/api/PostStream/{code}", "/api/PostStream");
更新到V1.9.9
[RouteMap("/map/{code}")]
[RouteMap("/map/{code}/{customer}")]
public object Map(string code, string customer)
{
return new { code, customer };
}
原来的方法是可以可以这样支持 [Post(Route = "{code}/{datacode}")] public JsonResult PostStream(IHttpContext context, string code, string datacode = null)
但我现在是想能够支持第二个参数可能会为空的情况,如: api/PostStream/PRJ20210701 api/PostStream/PRJ20210701/0501
当前测试,第一种路径会报 POST /PostStream/PRJ20210701 not found
像asp.net一样: [Route("Everything/MovieCustomer/")] [Route("Everything/MovieCustomer/{movieId}")] [Route("Everything/MovieCustomer/{movieId}/{customerId}")]