c# - HttpContext.Current.Request.Form.AllKeys in ASP.NET CORE version -
foreach (string key in httpcontext.current.request.form.allkeys) { string value = httpcontext.current.request.form[key]; } what .net core version of above code? seems .net core took out allkeys , replaced keys instead. tried convert above code .net core way, throws invalid operation exception.
httpcontext.request.form = 'httpcontext.request.form' threw exception of type 'system.invalidoperationexception'
converted code:
foreach (string key in httpcontext.request.form.keys) { }
your use this:
var dict = request.form.todictionary(x => x.key, x => x.value.tostring()); in case, can iterate on dictionary or can access values directly:
dict["hello"] = "world"
Comments
Post a Comment