我一直在嘗試使用ASP.Net MVC 4開發人員預覽DotNetOpenAuth示例。DotNetOpenAuth與MVC 4.0
我可以成功地調用我的行動從我的測試頁面,但碰到一個奇怪的問題的代碼,因爲的一行:
var request = _openid.CreateRequest(openIdUrl);
var fetch = new FetchRequest();
fetch.Attributes.AddRequired(WellKnownAttributes.Contact.Email);
fetch.Attributes.AddRequired(WellKnownAttributes.Name.First);
fetch.Attributes.AddRequired(WellKnownAttributes.Name.Last);
request.AddExtension(fetch);
//return RedirectToAction("Login");
return request.RedirectingResponse.AsActionResult(); // <-- This is the line throwing the error
如果我註釋掉的代碼有問題的行,並取消在此之前的一個,我再也看不到運行時錯誤了。
到目前爲止,我曾嘗試:
1)確保我有正確的重定向:
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Web.Helpers" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0" newVersion="2.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0" newVersion="2.0.0.0" />
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
</dependentAssembly>
</assemblyBinding>
<legacyHMACWarning enabled="0" />
</runtime>
2)具有正確的命名空間:
using DotNetOpenAuth.OpenId.Extensions.AttributeExchange;
using DotNetOpenAuth.OpenId.Extensions;
這在我看來, DotNetOpenAuth dll是針對MVC V 1.0.0編譯的,綁定重定向不是工作,或者擴展方法可能是針對不推薦使用的方法。
MVC版本:4.0.0.0 DotNetOpenAuth版本:3.4.7.11121
上得到這個與MVC 4個工作任何幫助將不勝感激。 的MVC錯誤屏幕圖像下面進一步:
更新 我發現AsActionResult是問題的原因,也許是因爲擴展方法是不能與.NET 4.0兼容。我可以從request.RedirectingResponse中獲得OutgoingWebResponse對象,但知道如何將其轉換爲ActionResult
是你的示例代碼,讓我可以看到OpenId與MVC4一起工作。當我調用提供程序按鈕時,我遇到了很多從圖像路徑到JS錯誤的問題。 – Picflight 2012-01-31 07:35:31