这段代码
@Html.TextBoxFor(m => m.UserName, new { @class = "validate[required]", disabled = "disabled", value = ViewBag.user[0].UserName }) @Html.ValidationMessage("usernameVal", "*")
当它到达时抛出异常ViewBag.user[0].UserName
例外:
'System.Web.Security.MembershipUserCollection.this[string]' 的最佳重载方法匹配有一些无效参数
行动:
public ActionResult EditUser()
{
//Resgata username do registro
string user = Request.QueryString["username"];
try
{ //Se nome foi resgatado
String.IsNullOrEmpty(user)
MembershipUserCollection muc = Membership.FindUsersByName(user);
ViewBag.user = muc;
return PartialView();
}
catch (Exception e)
{
return Content("Erro: " + e);
}
}