I have some belows , please help me how i can get Session in Javascript code from Controller ?
public ActionResult Login(FormCollection f)
{
string sAcount = f["txtAccount"].ToString();
string sPassword = f.Get("txtPassword").ToString();
tblCustom cs = db.tblCustoms.SingleOrDefault(n=>n.Account==sAccount && n.Password==sPassword);
if (cs != null)
{
Session["Account"] = cs;
return View();
}
return View();
}
and JS code is
<script >
$('#btnSendMsg').click(function () {
var msg = $("#txtMessage").val();
alert('Hello' + Session["Account"] );
});
<script/>
the result is alert stil is not working, help me.