【发布时间】:2015-11-16 16:34:34
【问题描述】:
发布 asp.net mvc 项目后,我注意到在调试模式下调用链接 http://localhost:56881/CPanel/login?role=form 时的 localhost 它正常返回登录视图。
但在发布后尝试调用http://domainname.com/CPanel/login?role=form 它给了我 500 - 内部服务器错误。
//Login Action >> CPanel Controller
public ActionResult login()
{
return View();
}
[HttpPost]
public ActionResult login(FormCollection customer, string ReturnUrl)
{
ViewBag.isError = false;
if (Session["SystemAdmin"] == null)
{
var u = new Egx.EgxBusiness.Inventory.User() { USER_NAME = customer["EMAIL_ADDR"] }.Search();
Crypto.VerifyHashedPassword(u[0].PASSWORD, customer["password"]);
if (u.Count > 0 && Crypto.VerifyHashedPassword(u[0].PASSWORD, customer["password"]))
{
var c = new Customers() { EMAIL_ADDR = customer["EMAIL_ADDR"] }.Search();
FormsAuthentication.SetAuthCookie(c[0].CUST_NAME, false);
Session["_customer"] = c[0];
if (Url.IsLocalUrl(ReturnUrl) && ReturnUrl.Length > 1 && ReturnUrl.StartsWith("/")
&& !ReturnUrl.StartsWith("//") && !ReturnUrl.StartsWith("/\\")) { return Redirect(ReturnUrl); }
else
{
return RedirectToAction("Index");
}
}
else
{
ViewBag.isError = true;
return View();
}
}
else
{
var c = new Customers() { EMAIL_ADDR = customer["EMAIL_ADDR"] }.Search();
if (c.Count == 0) { c = new Customers() {CUST_CODE=customer["EMAIL_ADDR"] }.Search(); }
if (c.Count > 0)
{
Session["_customer"] = c[0];
return RedirectToAction("Index");
}
else
{
ViewBag.isError = true;
return View();
}
}
}
登录查看
@using (Html.BeginForm("login", "CPanel", new { ReturnUrl = Request.QueryString["ReturnUrl"], role = "form" }))
{
if (Request.QueryString["r"] != null) { <input type="hidden" value="@Request.QueryString["r"]" name="r"/> }
<div class="form-group">
<input class="form-control" placeholder="E-mail" name="EMAIL_ADDR" type="text" autofocus>
</div>
<div class="form-group">
<input class="form-control" placeholder="Password" name="password" type="password" value="" @Html.Raw(EgxNMWeb.AuthSystemAdmin.isSystemAdmin()? "disabled":string.Empty)>
</div>
<div class="checkbox">
<label>
<input name="remember" type="checkbox" value="Remember Me">Remember Me
</label>
</div>
<!-- Change this to a button or input when using this as a form -->
<input type="submit" value="Login" class="btn btn-lg btn-success btn-block" />
@Html.Raw(EgxNMWeb.AuthSystemAdmin.isSystemAdmin()? "<a href="+Url.Action("Index","Finance")+">ماليات</a>":string.Empty)
}
【问题讨论】:
-
其他页面是否正常工作?
-
是的,一切都很好
标签: c# asp.net asp.net-mvc asp.net-mvc-3 asp.net-mvc-4