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

Popular posts from this blog

javascript - Confirm a form & display message if form is valid with JQuery -

Retrieving ETA (estimated time of arrival) with Google Distance Matrix API and public transit as transport mode -

ionic framework - Meteor - Error: Failed to execute 'insertBefore' on 'Node' -