怎么把viewData["userName"]传到home文件夹的index页面
我的AccountController里面想把viewdata["userName"]传到home的index页面中,要怎么传啊??
[HttpPost]
public ActionResult Login(FormCollection form)
{
if (CanLogin(form["userName"], form["password"]) == true)
{
ViewData["userName"] = form["userName"];
return RedirectToAction("Index", "Home" ,ViewData["userName"]);
}
return View();
}
<%@ Page Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage" %>
<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
主页
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
<h2>
<%: ViewData["Message"] %></h2>
<p>
欢迎:<%=ViewData["userName"]%></p>
</asp:Content>