What happened to FormCollections from System.Web.Mvc
? In the past I would use something like this string value = data.GetValues(key).FirstOrDefault();
where data is a formcollection. Now when I try to implement a FormCollection it comes from Microsoft.AspNet.Http.Internal
. Which doesnt contain the GetValues method.
I'm currently using beta 8 of MVC.
Seems like the form collection is now represented by the interface IFormCollection
which inherits from IReadableStringCollection
which is enumerable over the keys and values in the form collection passed in the http request. It can also be used to get to the values for a key through indexing:
var myValues = this.Request.Form[someKey];
You can access it via Request.Form
in controllers. Instead of GetValues
method, those values are accessed from it's indexer as:
var id = Request.Form["id"];
PS: If the given key does not exist, it does not return null or throw any exception. It returns StringValues.Empty
instead.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With