【发布时间】:2013-10-01 13:08:16
【问题描述】:
我一直在使用 DotNetOpenAuth。首先我们使用 5.0.0-alpha1,但我们切换到 v4.0.30319,因为我们找不到导致问题的原因。
我们正在 Visual Studio 2013 中使用 MVC 5 RC 在 .NET 4.5.1 RC 上构建 C# Web API 项目。我们已经实现了 IAuthorizationServerHost、INonceStore 和 ICryptoKeyStore。
我们遇到的问题是围绕以下情况:
public class TokensController : Controller
{
private readonly AuthorizationServer authorizationServer = new AuthorizationServer(new MyAuthorizationServer());
/// <summary>
/// This action will handle all token requests.
/// </summary>
/// <returns>The action result that will output the token response.</returns>
[HttpPost]
public ActionResult Index()
{
var outgoingWebResponse = this.authorizationServer.HandleTokenRequest(this.Request);
return outgoingWebResponse.AsActionResult();
}
}
return outgoingWebResponse.AsActionResult(); 起源于DotNetOpenAuth.Messaging 和MessagingUtilities 静态类的方法。 DotNetOpenAuth.Core(包含此代码)引用 MVC 4.0,HttpResponseMessageActionResult 类继承自 ActionResult。
这意味着当前版本的 DotNetOpenAuth 与 MVC 5 不兼容。编译并尝试运行它只会出现 500 错误。
有没有人知道如何轻松解决(或不解决)这个问题?
我没有注意到 DotNetOpenAuth Nuget 包覆盖了我的 5.0 包。所以在重新安装包并再次添加 assemblyBinding 后:
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-4.0.0.0" newVersion="5.0.0.0" />
</dependentAssembly>
</assemblyBinding>
这让我们更进一步。现在错误归结为:
尝试通过安全透明方法“DotNetOpenAuth.Messaging.MessagingUtilities.AsActionResult(DotNetOpenAuth.Messaging.OutgoingWebResponse)”访问安全关键类型“System.Web.Mvc.ActionResult”失败。
【问题讨论】:
标签: c# asp.net asp.net-mvc oauth-2.0 dotnetopenauth