angeldrop
دوشنبه 29 دی 1393, 04:00 صبح
سلام دوستان عزیز برنامه نویس
من اکشن و ویو login رو ساختم و اینکه کاربر به راحتی register میشه از طریق ارسال ایمیل اما وقتی که میخواد لاگین بشه authenticate نمیشه !
breakpoint هم گذاشتم ریز به ریز جاهاشو چک کردم !!
این اکشن login
[AllowAnonymous]
public ActionResult Login(string ReturnUrl)
{
return View();
}
//
// POST: /Account/Login
[HttpPost]
public ActionResult Login(LoginViewModel login, string ReturnUrl="")
{
var user = db.RegisterInfoes.FirstOrDefault(u => u.Email == login.Email && u.Password == login.Password);
if (user != null)
{
if (user.IsActive)
{
FormsAuthentication.SetAuthCookie(login.Email, login.RememberMe);
if (ReturnUrl !="")
{
return Redirect(ReturnUrl);
}
else
{
return Redirect("/");
}
}
else
{
ModelState.AddModelError("Email", "حساب کاربری فوق فعال نشده است");
return View(login);
}
}
else
{
ModelState.AddModelError("Email", "کاربری یا مقادیر فوق یافت نشد ");
return View(login);
}
}
اینم partial view
_LoginPartial
<div class="thumbnail">
@if (User.Identity.IsAuthenticated)
{
<div class="well well-sm text-center">
@User.Identity.Name خوش آمدید
</div>
<p>
<a href="/Account/LogOff">خروج از سایت</a>
</p>
}
else
{
<div class="well well-sm text-center">
کاربر مهمان خوش آمدید
</div>
<p>
<a href="/Account/Login">ورود به سایت</a>
</p>
<p>
<a href="/Account/Register">ثبت نام</a>
</p>
}
</div>
ذر اصل باید authnticate بشه و از قسمت IsAuthenticate صفحه بارگذاری بشه ولی میره روی else
ممنون میشم کمک کنید ..
من اکشن و ویو login رو ساختم و اینکه کاربر به راحتی register میشه از طریق ارسال ایمیل اما وقتی که میخواد لاگین بشه authenticate نمیشه !
breakpoint هم گذاشتم ریز به ریز جاهاشو چک کردم !!
این اکشن login
[AllowAnonymous]
public ActionResult Login(string ReturnUrl)
{
return View();
}
//
// POST: /Account/Login
[HttpPost]
public ActionResult Login(LoginViewModel login, string ReturnUrl="")
{
var user = db.RegisterInfoes.FirstOrDefault(u => u.Email == login.Email && u.Password == login.Password);
if (user != null)
{
if (user.IsActive)
{
FormsAuthentication.SetAuthCookie(login.Email, login.RememberMe);
if (ReturnUrl !="")
{
return Redirect(ReturnUrl);
}
else
{
return Redirect("/");
}
}
else
{
ModelState.AddModelError("Email", "حساب کاربری فوق فعال نشده است");
return View(login);
}
}
else
{
ModelState.AddModelError("Email", "کاربری یا مقادیر فوق یافت نشد ");
return View(login);
}
}
اینم partial view
_LoginPartial
<div class="thumbnail">
@if (User.Identity.IsAuthenticated)
{
<div class="well well-sm text-center">
@User.Identity.Name خوش آمدید
</div>
<p>
<a href="/Account/LogOff">خروج از سایت</a>
</p>
}
else
{
<div class="well well-sm text-center">
کاربر مهمان خوش آمدید
</div>
<p>
<a href="/Account/Login">ورود به سایت</a>
</p>
<p>
<a href="/Account/Register">ثبت نام</a>
</p>
}
</div>
ذر اصل باید authnticate بشه و از قسمت IsAuthenticate صفحه بارگذاری بشه ولی میره روی else
ممنون میشم کمک کنید ..