Using Html.BeginForm with querystring

前端 未结 7 1612
无人共我
无人共我 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:36

    To create a RouteValueDictionary from the querystring:

    RouteValueDictionary queryStringDictionary = new RouteValueDictionary(Request.QueryString.AllKeys.ToDictionary(key => key, key => (object)Request.QueryString[key]));
    

    Then you can use it with Html.BeginForm:

    Html.BeginForm(null, null, queryStringDictionary, FormMethod.Post, new Dictionary { { "autocomplete", "off" } })
    

提交回复
热议问题