我正尝试使用MVC 5 spa template
将新测试网站从Visual Studio 2013 RC
发布到azure。ASP.NET MVC 5身份和Azure
我可以得到注册/登录/注销过程工作得很好,除了有一个小问题困扰着我。如果我尝试使用错误的凭据登录,返回页面的错误字符串是“发生未知错误。”而不是“用户名或密码不正确。”因为它应该如果GrantResourceOwnerCredentials
在ApplicationOAuthProvider.cs
工作正常。
在本地主机上,我找回正确的“用户名或密码不正确。”信息。
错误日志从Azure中:
</head>
<body>
<div id="content">
<div class="content-container">
<h3>HTTP Error 400.0 - Bad Request</h3>
<h4>Bad Request</h4>
</div>
<div class="content-container">
<fieldset><h4>Most likely causes:</h4>
<ul> <li></li> </ul>
</fieldset>
</div>
<div class="content-container">
<fieldset><h4>Things you can try:</h4>
<ul> <li>Create a tracing rule to track failed requests for this HTTP status code. For more information about creating a tracing rule for failed requests, click <a href="http://go.microsoft.com/fwlink/?LinkID=66439">here</a>. </li> </ul>
</fieldset>
</div>
<div class="content-container">
<fieldset><h4>Detailed Error Information:</h4>
<div id="details-left">
<table border="0" cellpadding="0" cellspacing="0">
<tr class="alt"><th>Module</th><td> __DynamicModule_Microsoft.Owin.Host.SystemWeb.OwinHttpModule, Microsoft.Owin.Host.SystemWeb, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35_08fdea3d-9972-4dc2-b0fc-c8ffdb2e4253</td></tr>
<tr><th>Notification</th><td> AuthenticateRequest</td></tr>
<tr class="alt"><th>Handler</th><td> ExtensionlessUrlHandler-Integrated-4.0</td></tr>
<tr><th>Error Code</th><td> 0x00000000</td></tr>
</table>
</div>
<div id="details-right">
<table border="0" cellpadding="0" cellspacing="0">
<tr class="alt"><th>Requested URL</th><td> http://[site]:80/Token</td></tr>
<tr><th>Physical Path</th><td> C:\DWASFiles\Sites\[site]\VirtualDirectory0\site\wwwroot\Token</td></tr>
<tr class="alt"><th>Logon Method</th><td> Not yet determined</td></tr>
<tr><th>Logon User</th><td> Not yet determined</td></tr>
</table>
<div class="clear"></div>
</div>
</fieldset>
</div>
<div class="content-container">
<fieldset><h4>More Information:</h4>
The request could not be understood by the server due to malformed syntax.
<p><a href="http://go.microsoft.com/fwlink/?LinkID=62293&IIS70Error=400,0,0x00000000,9200">View more information »</a></p>
<p>Microsoft Knowledge Base Articles:</p>
我不知道,因为相同的语法被发送,当正确的登录凭据提交处理它如何是语法错误。
有没有人有足够的熟悉知道这是怎么回事,或者至少有一条路要走近知识库文章以外的答案?如果它不是很明显,那么我是新手 - 这是我在ASP.NET中的第一个网站,OAuth的第一次介绍,以及Azure的第一次使用。
我一直在看fiddler中的POST标题和请求正文,我看不到有良好凭据的登录语法和具有错误凭据的语法之间的区别。有其他人有这个问题吗?也许这是一个与这是新的mvc 5身份系统相关的错误?也许说明问题的azure日志格式错误。 – user2787092
看来,这不是一个Azure问题,而是ASP.NET MVC。也许在你的代码中,你会显示用户的名字,但是你没有检查身份是否与空值不同。一个好的提示:启用Nugget Elmah并重复此测试。你将能够看到错误和堆栈跟踪。 –
我应该提到代码在localhost上工作。它只返回Azure上的“发生未知错误”,我只是更新了原文,以表明这一点,但我会考虑Elmah,谢谢你的建议。 – user2787092