DotNetOpenAuth与MVC 5 RC工作 [英] DotNetOpenAuth not working with MVC 5 RC

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

问题描述

我已经工作了很多DotNetOpenAuth。首先,我们使用的5.0.0-ALPHA1但我们切换到v4.0.30319,因为我们找不到什么造成我们的问题。

我们是在.NET 4.5.1建立一个C#的Web API项目RC与MVC 5 RC在Visual Studio 2013年我们实施 IAuthorizationServerHost INonceStore ICryptoKeyStore

这是我们的问题都是围绕着以下情况:

 公共类TokensController:控制器
{
    私人只读AuthorizationServer authorizationServer =新AuthorizationServer(新MyAuthorizationServer());    ///<总结>
    ///此操作将处理所有的令牌请求。
    ///< /总结>
    ///<返回>该行动的结果将输出令牌响应< /回报>
    [HttpPost]
    公众的ActionResult指数()
    {
        VAR outgoingWebResponse = this.authorizationServer.HandleTokenRequest(this.Request);
        返回outgoingWebResponse.AsActionResult();
    }
}

返回outgoingWebResponse.AsActionResult(); DotNetOpenAuth.Messaging 有渊源的方法和 MessagingUtilities 静态类。在 DotNetOpenAuth.Core (其中包含此code)引用了MVC 4.0和的Htt presponseMessageActionResult 类从的ActionResult 继承。

这意味着DotNetOpenAuth的不是当前版本的MVC 5.编译兼容,并尝试运行,这将只是区分500错误。

有没有人有任何想法如何可以很容易地固定(或可能不是)?

我没有注意到DotNetOpenAuth的NuGet包在我写的包5.0。因此,重新安装包,再加入assemblyBinding后:

< assemblyBinding的xmlns =瓮:架构 - 微软COM:asm.v1>
  < dependentAssembly>
    < assemblyIdentity名称=System.Web.Mvc公钥=31bf3856ad364e35/>
    < bindingRedirect oldVersion =1.0.0.0-4.0.0.0NEWVERSION =5.0.0.0/>
  < / dependentAssembly>
< / assemblyBinding>

这让我们远一点。现在的错误归结为:


  

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



解决方案

修正可用。

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

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.

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(); 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.

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

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:

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

解决方案

Fix available.

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

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

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