10

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

pgSystemTester
  • 8,979
  • 2
  • 23
  • 49
parliament
  • 21,544
  • 38
  • 148
  • 238

1 Answers1

5

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

Community
  • 1
  • 1
mellodev
  • 1,597
  • 12
  • 20
  • Thanks for your reply but this did not work for me. I had all those dll's (and a few others to be sure) copied to my wwwroot/bin folder on the server but this didnt fix the issue. Since only Register and Login controller dont work and others due I suspect my database was not copied over. There is no option to include App_Data files when I use VS publish feature and I do not see the db anywhere on the server. This is probably the problem I will research it now since Ive never done before but any comments to make this possibly easier are of course welcome :) thanks – parliament Mar 22 '12 at 23:10
  • Can you edit your post to include the actual 500 error detail? Turn off 'friendly error messages' in your browser and enable customErrors element in web.config so you can see the actual error message. http://msdn.microsoft.com/en-us/library/h0hfz6fc.aspx – mellodev Mar 22 '12 at 23:33
  • I added to my web.config file and turned off friendly error messages: the error is the same, simply: 500 - Internal server error. There is a problem with the resource you are looking for, and it cannot be displayed. – parliament Mar 22 '12 at 23:53
  • is this considered a detailed message or did I do something wrong – parliament Mar 23 '12 at 00:33
  • 2
    Actually it needs to be set customErrors to "Off". This should cause the actual exception(s) to be shown, rather than the generic "500 server error" message. Once you see the actual exception I'm sure you'll know what to fix. Don't forget to reset this setting when you're done, to prevent details of your code/exceptions going to users. GL – mellodev Mar 23 '12 at 01:03