Action Parameter Naming

后端 未结 4 549
情书的邮戳
情书的邮戳 2020-12-25 11:18

Using the default route provided, I\'m forced to name my parameters \"id\". That\'s fine for a lot of my Controller Actions, but I want to use some better variable naming i

4条回答
  •  生来不讨喜
    2020-12-25 11:59

    Use the [Bind] attribute:

    public ActionResult ByAlias([Bind(Prefix = "id")] string alias) {
        // your code here
    }
    

提交回复
热议问题