0

I have a controller that receives the parameter t, but inside the function, It won't work with name type for the variable, is it possible like the example:

public ActionResult Find(int t as type = 0){
    if(type == 0)
        return NotFound();
    //code here
    return View();
}
juharr
  • 31,741
  • 4
  • 58
  • 93
Vitor Pereira
  • 43
  • 1
  • 3

1 Answers1

2

Assuming this is about the representation of your API to the outside, you can use attributes to influence the design of your API regardless of variable names you use internally in your code:

public ActionResult Find([FromQuery(Name = "t")]int type = 0)

Now to call it over the network, you would call it with t=17 but your internal C# variable name is type.

nvoigt
  • 75,013
  • 26
  • 93
  • 142