我一直在尝试使用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