DotNetOpenAuth 不适用于 MVC 5 RC [英] DotNetOpenAuth not working with MVC 5 RC

查看:20
本文介绍了DotNetOpenAuth 不适用于 MVC 5 RC的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在使用 DotNetOpenAuth.一开始我们使用了 5.0.0-alpha1,但我们切换到了 v4.0.30319,因为我们找不到导致问题的原因.

I have been working a lot with DotNetOpenAuth. First we used 5.0.0-alpha1 but we switched over to v4.0.30319 because we couldn't find what was causing our problems.

我们正在 Visual Studio 2013 中使用 MVC 5 RC 在 .NET 4.5.1 RC 上构建 C# Web API 项目.我们已经实现了 IAuthorizationServerHostINonceStore 和 <代码>ICryptoKeyStore.

We are building a C# Web API project on .NET 4.5.1 RC with MVC 5 RC in Visual Studio 2013. We have implemented IAuthorizationServerHost, INonceStore, and ICryptoKeyStore.

我们遇到的问题围绕以下情况:

The problem that we have are around the following case:

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.MessagingMessagingUtilities 静态类的方法.DotNetOpenAuth.Core(包含此代码)引用 MVC 4.0,HttpResponseMessageActionResult 类继承自 ActionResult.

return outgoingWebResponse.AsActionResult(); a method with origins in DotNetOpenAuth.Messaging and the MessagingUtilities static class. The DotNetOpenAuth.Core (which contains this code) references MVC 4.0 and the HttpResponseMessageActionResult class inherits from ActionResult.

这意味着当前版本的 DotNetOpenAuth 与 MVC 5 不兼容.编译并尝试运行它只会出现 500 个错误.

This means the current version of DotNetOpenAuth in not compatible with MVC 5. Compiling and trying to run this will just case 500 errors.

有没有人知道如何轻松解决(或可能不解决)这个问题?

Does anyone have any ideas how this could be easily fixed (or maybe not)?

我没有注意到 DotNetOpenAuth Nuget 包覆盖了我的 5.0 包.所以在重新安装软件包并再次添加 assemblyBinding 后:

I didn't notice that the DotNetOpenAuth Nuget package wrote over my packages for 5.0. So after reinstalling the packages and adding the assemblyBinding again:

<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>

这让我们更进一步.现在错误归结为:

This got us a little further. Now the error comes down to:

尝试通过安全透明方法DotNetOpenAuth.Messaging.MessagingUtilities.AsActionResult(DotNetOpenAuth.Messaging.OutgoingWebResponse)"访问安全关键类型System.Web.Mvc.ActionResult"失败.

Attempt by security transparent method 'DotNetOpenAuth.Messaging.MessagingUtilities.AsActionResult(DotNetOpenAuth.Messaging.OutgoingWebResponse)' to access security critical type 'System.Web.Mvc.ActionResult' failed.

推荐答案

可用修复.

安装 NuGet 包 DotNetOpenAuth.Mvc5 并将 AsActionResult() 的所有使用更改为 AsActionResultMvc5()

Install NuGet package DotNetOpenAuth.Mvc5 and change all uses of AsActionResult() to AsActionResultMvc5()

这篇关于DotNetOpenAuth 不适用于 MVC 5 RC的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆