ASP.NET MVC: The right way to propagate query parameter through all ActionLinks

前端 未结 6 2290
礼貌的吻别
礼貌的吻别 2020-12-15 13:27

In my application, key query string parameter can be used to grant access to certain actions/views.
Now I want all ActionLinks and Forms to automatically in

6条回答
  •  粉色の甜心
    2020-12-15 14:08

    The simplest thing is to put the "key" parameter in all the Url.Action and Html.ActionLink in this way:

    @Url.Action("MyAction", "MyController", new { key = Request["key"] })
    

    if Request["key"] is empty the querystring parameter will be skipped.

提交回复
热议问题