如果我们在动作方法中放置一个变量(比如myvariable
),例如
[RoutePrefix("api/myservice")]
public class MyApiController : ApiController
{
[Route("")]
[HttpGet]
public HttpResponseMessage GetVar([FromUri] string myvariable = "")
{
var response = Request.CreateResponse(HttpStatusCode.OK, "");
return response;
}
}
,api的网址将如下所示:
api/myservice?myvariable={ myvariable }
但我希望看到它:
api/myservice?myvariable={ var }
var
或其他任何内容,而不是myvariable
。
如何在不更改路线表的情况下进行此操作?