gpt4 book ai didi

c# - DotNetOpenAuth 不适用于 MVC 5 RC

转载 作者:IT王子 更新时间:2023-10-29 04:01:11 31 4
gpt4 key购买 nike

我经常使用 DotNetOpenAuth。首先我们使用 5.0.0-alpha1 但我们切换到 v4.0.30319 因为我们找不到导致我们问题的原因。

我们正在使用 Visual Studio 2013 中的 MVC 5 RC 在 .NET 4.5.1 RC 上构建一个 C# Web API 项目。我们已经实现了 IAuthorizationServerHostINonceStoreICryptoKeyStore.

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

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

这意味着当前版本的 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>

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

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

关于c# - DotNetOpenAuth 不适用于 MVC 5 RC,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19013429/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com