简体   繁体   中英

How do I diagnose why an asp.net MVC site works on one server but not another?

I have a asp.net MVC with Razor site that works fine on my PC and our company's test server. However, on the client's web server it gets "stuck" on the login page. I can't debug the site on the client's server (they don't have Visual Studio) and I can't duplicate the problem anywhere else. Any suggestions on how to find the problem? Also, any idea what the problem might be?

So I have a login page where the user enters their user name and password and clicks a "sign in" submit button. When they click submit, the browser gets "stuck"; that is the the "working" icon spins (I'm using Chrome) while at the bottom of the page it shows the message "waiting on {site name}...".

Here's some code from the view:

@using (Html.BeginForm("Login", "Admin", FormMethod.Post))
{
           <label>
             <b>Username</b>
           </label>
           @Html.TextBoxFor(m => m.UserName, new { @class = "span12" })
           <span class="validation">@Html.ValidationMessageFor(m => m.UserName)</span>

           <label>
             <b>Password</b>
           </label>
           @Html.PasswordFor(m => m.Password, new { @class = "span12" })

           <input id="Submit1" type="submit" value="Sign In" class="btn btn-primary pull-right" />
}

Here's a portion of the controller. I left out some error handling, but you'll get the idea that it's a simple "check if username and password exists" operation.

        [HttpPost]
        public ActionResult Login(ModelAdminLogin Model)
        {
            if (ModelState.IsValid) 
            {
                LoginResponse Res = obj_bllCA.Login(Model.UserName, Model.Password);
                if (Res.LoginStatus)
                {
                  return RedirectToAction("Index");
                }
            }
            return View(Model);
        }

On the login page, after enter login information and clicking sign in, it "spins" for a few minutes and then shows a page not found message:

在此处输入图片说明

Strangely, if you then click refresh, it shows the correct page with the user logged in.

Again, on my PC in Visual Studio and my company's web server, the login process works fine. The user enters the username and password, clicks Sign In, and it takes them to the next page. Only on the client's server does it instead go to the missing page.

UPDATE #1

Using Fiddler, I got this error message to display:

ReadResponse() failed: The server did not return a complete response for this request. Server returned 0 bytes.

Using the Chrome tools, I can see it stalls after the submit button is clicked:

在此处输入图片说明

It looks like it's not posting to the controller. Anyone have a suggestion on how to fix this?

How do I diagnose why an asp.net MVC site works on one server but not another?

Using chrome dev tools you can diagnose why something isn't working:

Internal server error: (In this case a 500 internal server error)

在此处输入图片说明

You can click on the specifc request and then click the preview to get the details:

在此处输入图片说明

Based on ReadResponse error, it seems like it is an IIS configuration issue:

  • If you have HTTPS, check if corresponding bindings, ports and certificates are correct.
  • If you use rewrites, check if URLRewrite module is installed.

In general:

  • Enable IIS logging and look at logs.
  • Enable Failed request tracing in IIS and look at traces.
  • Make sure you handle Application_Error and write exception details into logs.

The answer turned out to be that the client had set up the site in IIS to be a secure site. I had to use https://sitename.com instead of sitename.com or http://sitename.com . Once I did that, all the pages worked. I don't understand why the original page worked without the https or why hitting refresh showed the correct page without the https, so if anyone has any input on that please let me know. Otherwise the https was the whole problem.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM