我有一个接收参数的控制器t
,但在函数内部,它不适type
用于变量名称,是否可能像示例一样:
public ActionResult Find(int t as type = 0){
if(type == 0)
return NotFound();
//code here
return View();
}
假设这是关于您的 API 对外的表示,您可以使用属性来影响您的 API 的设计,而不管您在代码内部使用的变量名称如何:
public ActionResult Find([FromQuery(Name = "t")]int type = 0)
现在要通过网络调用它,您可以使用它来调用它,t=17
但是您的内部 C# 变量名称是type
.
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句