s.k*_*aul 7 c# asp.net-mvc formcollection
我在mvc控制器中收到一些数据作为FormCollection.我想检查formcollection中是否存在特定的密钥.
public JsonResult FullRetailerUpdate(FormCollection data)
{
//I want to check if
//data["AnElement"] is exist
}
Run Code Online (Sandbox Code Playgroud)
请帮忙.
Kar*_*sla 17
尝试使用.Contains(): -
public JsonResult FullRetailerUpdate(FormCollection data)
{
if (data.AllKeys.Contains("AnElement"))
{
// Your Stuff
}
else
{
// Your Stuff
}
}
Run Code Online (Sandbox Code Playgroud)