Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Asp.net MVC4 - Internal Server 500 error - Only when published

Just finished up my first mvc4 app. Everything is working great until I deploy it and I get: 500 - Internal server error. There is a problem with the resource you are looking for, and it cannot be displayed. every time I try to call /Account/Register or /Account/Login controllers:

I've snooped around in firefox console and fiddler. I didn't find anything useful there, but then again I don't really know what I should even be looking for.

Some other posts say to check the server log but that's a problem in itself because when I try to download, move, view, or delete the latest log file I get errors like "file transfer failed", "550 cant access file", "500 failed to delete file".

I don't know what else to do, some please advice. Heres some code for call to Login controller. I won't post Register version since they seem related.

Ajax call:

$.ajax({
                    url: "/Account/Login",
                    type: "POST",
                    data: $('#loginForm').serialize(),
                    success: function (resultData) {
                        if (resultData.ok) {
                            ...unrelated stuff...has call to resultData.message
                        }
                    }
                });

Login controller:

    [AllowAnonymous]
    [HttpPost]
    public ActionResult Login(LoginModel model)
    {

        if (ModelState.IsValid)
        {
            if (Membership.ValidateUser(model.UserName, model.Password))
            {
                FormsAuthentication.SetAuthCookie(model.UserName, model.RememberMe);
                return Json(new { ok = true, message = "Login successful." });
            }
            else
            {
                return Json(new { ok = false, message = "The username or password you entered is invalid. Please try again." });
            }
        }

        // If we got this far, something failed, redisplay form
        return View(model);
    }

It all seems pretty standard here so I really don't know what it could be or how to even diagnose

like image 847
parliament Avatar asked Mar 22 '12 06:03

parliament


1 Answers

I ran into a similar issue, which was a result of certain referenced DLLs not being present in the GAC of the server (only on the dev machine with the MVC4 beta installed). The solution was to set those dependencies to "Copy to Local" before compilation

* System.Web.Mvc
* System.Web.Routing
* System.Web.Abstractions
* Microsoft.Web.Infrastructure
* System.Web.Razor
* System.Web.WebPages.Deployment
* System.Web.WebPages.Razor

If you're having the same problem these links will help you solve it:

Could not load file or assembly 'System.Web.Mvc'

http://haacked.com/archive/2008/11/03/bin-deploy-aspnetmvc.aspx

like image 187
mellodev Avatar answered Sep 21 '22 10:09

mellodev