发布asp.net mvc项目后,我注意到在调试模式的localhost中调用链接http://localhost:56881/CPanel/login?role=form 它正常返回登录视图。
但在尝试拨打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)
}
答案 0 :(得分:0)
尝试清理解决方案并再次构建并发布。另外,将自定义错误模式设置为关闭。如果您能给我们一个特定的错误,我们可能会帮助您解决更多问题。还要确保本地计算机上的身份验证模式与您要发布的服务器上的身份验证模式相匹配。