PDA

View Full Version : انتقال به صفحه login.aspx?ReturnUrl=%2fadmin!!!!



forestasphalt
شنبه 21 اردیبهشت 1392, 11:28 صبح
با سلام
این کدهای قسمت ادمینه سایته

[Authorize]
public class AdminController : Controller
{
[AllowAnonymous]
public ActionResult LogOn(string ReturnUrl)
{
ViewBag.ReturnUrl = ReturnUrl;
return View();
}
[AllowAnonymous]
[HttpPost]
public ActionResult LogOn(string Username, String Password)
{

Password = FormsAuthentication.HashPasswordForStoringInConfig File(Password, "MD5");
using (var db = new PerspolisEntities1())
{
var q = db.Users.SingleOrDefault(p => p.UserName.Equals(Username) && p.Password.Equals(Password));
try
{
if (q.UserName.Count() > 0)
{


return View("Index");

}
else
{
return View("LogOn");
}
}
catch
{
return View("LogOn");
}

}//end using

}




و در وب کانفینگ روت


<authentication mode="Forms">
<forms loginUrl="~/Admin/LogOn" timeout="2880" />
</authentication>

ولی هنگامی که میخوایم به کنترلر ادمین وارد بشم میره به صفحه login.aspx?ReturnUrl=%2fadmin
به نظرتون مشکل از کجاست؟!

mo.esmp
یک شنبه 22 اردیبهشت 1392, 14:30 عصر
if (q.UserName.Count() > 0)
{
FormsAuthentication.SetAuthCookie(UserName, createPersistentCookie:true);
return View("Index");

}

forestasphalt
دوشنبه 23 اردیبهشت 1392, 13:40 عصر
مرسی مشکلم حل شد:لبخندساده: