How to pass query string parameter in ActionLink in MVC

后端 未结 4 584
悲&欢浪女
悲&欢浪女 2021-02-03 16:52

I am having following action link:

<%= Html.ActionLink(\"Check this\", \"Edit\", \"test\", 
                     new { id = id }, new { style = \"display:bloc         


        
4条回答
  •  失恋的感觉
    2021-02-03 17:37

    I got tired of banging my head against a wall with the html.actionlink. Works great when you just want to route it against straightforward routing calls, but absolutely refuses to cooperate when you want to add a simple querystring at the end.

    I don't an ID at then end, I want to be able to add some kind of actual Querystring with the "?".

    So anywhere I needed a Querystring I switched to using the url.action inside the anchor tag.

    Text for Link Name
    

    At least it works and I can stop getting headaches over something that should have been a very simple task. Someone needs to get their heads out of their butts and make the ActionLink work properly for Querystrings in the MVC routing.

提交回复
热议问题