Form Deficiencies in ASP.Net 5

What happened to FormCollections from System.Web.Mvc ? Previously, I would use something like this string value = data.GetValues(key).FirstOrDefault(); where the data are forms. Now when I try to implement FormCollection, it comes from Microsoft.AspNet.Http.Internal . What the GetValues ​​method does not contain.

I am currently using beta version 8 of MVC.

+6
source share
2 answers

It seems that the form collection is now represented by the IFormCollection interface, which inherits from IReadableStringCollection , which is enumerated by the keys and values ​​in the form collection passed in the HTTP request. It can also be used to get values ​​for a key by indexing:

 var myValues = this.Request.Form[someKey]; 
+7
source

You can access it through Request.Form in controllers. Instead of the GetValues method GetValues these values ​​get from it an indexer as:

 var id = Request.Form["id"]; 

PS: If the given key does not exist, it does not return null or throws any exception. Instead, it returns StringValues.Empty .

+3
source

All Articles