简体   繁体   English

我如何诊断为什么一个asp.net MVC站点可以在一台服务器上运行而不能在另一台服务器上运行?

[英]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. 我有一个带有Razor站点的asp.net MVC,可以在我的PC和我们公司的测试服务器上正常工作。 However, on the client's web server it gets "stuck" on the login page. 但是,在客户端的Web服务器上,它会在登录页面上“卡住”。 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. 我无法在客户端服务器上调试站点(它们没有Visual Studio),并且无法在其他任何地方重复该问题。 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}...". 即“正在运行”图标旋转(我正在使用Chrome),而在页面底部则显示消息“正在等待{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. 同样,在Visual Studio的PC和公司的Web服务器上,登录过程可以正常进行。 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 更新#1

Using Fiddler, I got this error message to display: 使用Fiddler,我得到此错误消息显示:

ReadResponse() failed: The server did not return a complete response for this request. ReadResponse()失败:服务器未对此请求返回完整的响应。 Server returned 0 bytes. 服务器返回了0个字节。

Using the Chrome tools, I can see it stalls after the submit button is clicked: 使用Chrome工具,单击提交按钮后,它会停滞:

在此处输入图片说明

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? 我如何诊断为什么一个asp.net MVC站点可以在一台服务器上运行而不能在另一台服务器上运行?

Using chrome dev tools you can diagnose why something isn't working: 使用chrome开发工具,您可以诊断为什么某些功能无法正常工作:

Internal server error: (In this case a 500 internal server error) 内部服务器错误:(在这种情况下为500个内部服务器错误)

在此处输入图片说明

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: 基于ReadResponse错误,似乎是IIS配置问题:

  • If you have HTTPS, check if corresponding bindings, ports and certificates are correct. 如果您具有HTTPS,请检查相应的绑定,端口和证书是否正确。
  • If you use rewrites, check if URLRewrite module is installed. 如果使用重写,请检查是否安装了URLRewrite模块。

In general: 一般来说:

  • Enable IIS logging and look at logs. 启用IIS日志记录并查看日志。
  • Enable Failed request tracing in IIS and look at traces. 在IIS中启用“失败的请求跟踪”,然后查看跟踪。
  • Make sure you handle Application_Error and write exception details into logs. 确保处理Application_Error并将异常详细信息写入日志。

The answer turned out to be that the client had set up the site in IIS to be a secure site. 答案是,客户端已在IIS中将站点设置为安全站点。 I had to use https://sitename.com instead of sitename.com or http://sitename.com . 我必须使用https://sitename.com而不是sitename.com或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. 我不明白为什么原始页面在没有https的情况下起作用,或者为什么单击刷新会显示没有https的正确页面,所以如果有人对此有任何输入,请告诉我。 Otherwise the https was the whole problem. 否则,https是整个问题。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在ASP.NET MVC中将所选项目从一页传递到另一页 - How do I Pass Selected items from one page to another page in asp.net mvc 如何在ASP.NET MVC4中将ID从一个视图携带到另一个视图? - How do I carry an Id from one view to another, in ASP.NET MVC4? 如何将一个表格数据与另一个表格数据匹配,然后显示匹配的数据? ASP.NET MVC - How do I match one table data to another then display the matched data? ASP.NET MVC 如何使一个ASP.NET MVC站点从另一个“派生” - How to make one ASP.NET MVC site “derive” from another 如何从ASP.NET MVC中的同一操作重定向到另一个视图或外部站点? - How can I redirect to either another view or an external site from the same action in ASP.NET MVC? 如何在ASP.NET MVC 3站点中执行后台作业? - How to do background jobs in an ASP.NET MVC 3 site? 我可以使用带有实体框架(asp.net mvc)的另一台服务器上的一台服务器上的存储过程吗? - Can I use a stored procedure from one server on another with entity framework (asp.net mvc)? 完成动作后,如何在ASP.NET MVC中将某人从一个动作重定向到另一个动作? - How do I redirect someone from one action to another in ASP.NET MVC when an action has completed? 如何识别从其他地方返回我的ASP.NET MVC网站的用户? - How do I identify a user returning to my ASP.NET MVC site from elsewhere? 如何在 ASP.NET MVC 站点中实施速率限制? - How do I implement rate limiting in an ASP.NET MVC site?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM