[英]Routing controller with optional Id not in parameters
I'm currently struggling in a problem where I need to register a route like:我目前在一个需要注册路线的问题中苦苦挣扎:
https://localhost:44300/oneController/{Guid}/method1?param1=10000¶m2=stuff
What I've tried was something similar to this:我试过的是类似的东西:
[HttpGet]
public async Task<ActionResult> method1(Guid id, int param1, string param2)
{
...
}
However, this does not seems to work, any ideas to resolve this issue?但是,这似乎不起作用,有什么想法可以解决这个问题吗?
You can use RouteAttribute
, like您可以使用RouteAttribute
,例如
[Route("{id:guid}/method1"), HttpGet]
public async Task<ActionResult> method1(Guid id, int param1, string param2)
{
...
}
Good to read MSDN Documentation: Attribute Routing in ASP.NET适合阅读 MSDN 文档: ASP.NET 中的属性路由
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.