Using Html.BeginForm with querystring

前端 未结 7 1610
无人共我
无人共我 2021-01-01 09:44

My url looks like this:

customer/login?ReturnUrl=home

In the login view, I have used this pattern of code which works fine.



        
7条回答
  •  灰色年华
    2021-01-01 10:30

    I guess this doesn't directly answer the question, but why not just use a plain old form tag?

     

    Alternatively, you can create a custom HtmlHelperExtension that renders a form with path and querystring. In this HtmlHelperExtension you can iterate through your querystring values and populate the routeValueDictionary which you then pass to a Html.BeginForm constructor.

    If you don't want something so extensible you can just use the overloaded constructor of Html.BeginForm using @Html.BeginForm("login", "customer", new {ReturnUrl = @Request.QueryString["ReturnUrl"]},FormMethod.Post, new {data-id="something"});

提交回复
热议问题