ASP.NET MVC 参数为NULL异常
直接上代码:
CONTROLER:
public ActionResult ProductHome()
{
//ViewData["Content"] = cs.GetAll();
ViewData["Content"] = Get();
return View();
}
private ArrayList Get()
{
IList<HelperContent> ls = new List<HelperContent>();
ls = cs.GetAll();
//IList < string> lls = new List<string>();
ArrayList myarr = new ArrayList();
if (ls != null)
{
foreach (HelperContent hcon in ls)
{
string rs = hcon.Parentfolder;
string result = rs.Substring(rs.IndexOf("Content") + 7, rs.Length - rs.IndexOf("Content") - 7);
//int i = result.IndexOf("/", 2);
myarr.Add(result);
//lls.Add(hcon.Parentfolder);
}
}
return myarr;
}
这段代码不需要仔细看,就是把截取的string 全部装到arraylist 里去。。。
VIEW:
<% IList<string> Arrylist = (ViewData["Content"] as IEnumerable<string>).ToList<string>(); %>
到这就报错了
argumentnull exception was unhandled by user code