简体   繁体   English

没有数据返回查看

[英]No data being returned to view

HomeController HomeController的

[ValidateInput(false)]
public ActionResult Index()
{
    FormsAuthentication.SignOut();
    Session.Clear();
    Session.Abandon();
    EmployeeViewModel evm = new EmployeeViewModel();
    ViewBag.wresult = Request.Form["wresult"];
    if (!string.IsNullOrWhiteSpace(Request.Form["wresult"]))
    {
        XmlDocument wresult = new XmlDocument();
        wresult.LoadXml(Request.Form["wresult"]);
        XmlNodeList elemList = wresult.GetElementsByTagName("saml:Attribute");
        foreach (XmlNode node in elemList)
        {
            foreach (XmlAttribute attr in node.Attributes)
            {
                if (attr.Name.Equals("AttributeName") && attr.Value.Equals("emailaddress"))
                {
                    XmlNode child = node.FirstChild;
                    evm.EmployeeEmailId = child.InnerText;
                }
            }
        }
    }
    var emp = empModel.Get(evm.EmployeeEmailId);
    if (condition)
    {
        return RedirectToAction("Index", "XYZ", new { area = "PQR" });
    }
    return View("Test", evm)
}

The data that I am storing in the ViewBag here, as well as the object being returned with the view are returning blanks. 我在这里存储在ViewBag中的数据以及随视图返回的对象都返回空白。 I am unable to understand why this is. 我不明白为什么会这样。

evm object gets populated during the XML Processing, and there are some DB actions that happen to add more details to the object. evm对象在XML处理期间被填充,并且有一些数据库操作恰巧会向该对象添加更多详细信息。

EmployeeViewModel evm = new EmployeeViewModel();

This is the first and last time you make use of evm before trying to return it. 这是您第一次尝试使用evm,最后一次尝试返回它。 You're returning a new, blank instance of EmployeeViewModel() . 您将返回EmployeeViewModel()的新的空白实例。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM