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

How to understand 2 main() functions after using uftrace to profile the C++ program? -

c# - Update a combobox from a presenter (MVP) -

How to put a lock and transaction on table using spring 4 or above using jdbcTemplate and annotations like @Transactional? -