Url Helper RRS feed

  • Question

  • User-1572886696 posted


    How to re-write Url.ActionParametrized("actionname", New With {.ID= "{1}"}) in C#

    because when i wrote this

    Url.Action("actionname", new { ID= "{1}" }); 

    in the execution i see that :   


    Thank you.

    Thursday, June 4, 2020 2:04 PM

All replies

  • User-474980206 posted

    UrlHelper, generates a url, not a route path. The anonymous object will generate the query string, you need to pass the actual value you want query parameter to be.

    Thursday, June 4, 2020 2:18 PM
  • User1686398519 posted

    Hi,  windows2056

    You can write like this:

    @Url.Action("About", "Home", new { ID = 1})
    @Url.Action("About", "Home", new { test = "1" })

    More details, you could refer to this link:http://techfunda.com/howto/251/get-url-of-action-method.

    Here is the result.

    Best Regards,


    Friday, June 5, 2020 1:12 AM