samedi 22 août 2015

Asp.net mvc project give me internal server error after publisihng

after publishing asp.net mvc project i noticed that in localhost in debug mode when call link http://localhost:56881/CPanel/login?role=form it return login view normally .

but after publishing it when try to call http://ift.tt/1EMG06d it gave me 500 - Internal server error.

//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();
            }
        }
    }

Login 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)
                    }

Aucun commentaire:

Enregistrer un commentaire