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
به نظرتون مشکل از کجاست؟!
این کدهای قسمت ادمینه سایته
[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
به نظرتون مشکل از کجاست؟!