Search code examples
asp.net-mvcasp.net-corebetaformcollection

FormCollections missing from ASP.Net 5


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.


Solution

  • 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];