使用ToString()的ActionResult重定向渲染 [英] ActionResult redirect renders using ToString()

查看:123
本文介绍了使用ToString()的ActionResult重定向渲染的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用以下示例: http://www.west-wind. com/Weblog/posts/899303.aspx

以下行...

return req.RedirectingResponse.AsActionResult();

提供字符串"DotNetOpenAuth.Messaging.OutgoingWebResponseActionResult". 这是在发布的行中作为ActionResult返回的类.有谁知道为什么我将类名作为字符串而不是实际的重定向?

renders the string "DotNetOpenAuth.Messaging.OutgoingWebResponseActionResult". This is the class being returned as ActionResult in the line as posted. Does anyone know why I get the class name as string instead of a actual redirect?

提前感谢!

推荐答案

在Bin目录和Web服务器中是否存在MVC的多个版本?令我惊讶的是,如果您在AppDomain中加载了诸如ActionResult之类的MVC类型的多个程序集(不同版本),并且AsActionResult方法返回了一个版本,而您的MVC Web应用程序使用了另一个版本,则可能只是保释用ToString退出.您正在运行什么版本的ASP.NET MVC? DotNetOpenAuth的AsActionResult方法是针对MVC框架的1.0 RTM版本编译的.如果您使用的是ASP.NET MVC 2(包含在.NET 4.0中),则可能会出现问题.

Could it be that you have multiple versions of MVC in your Bin directory and your web server? It strikes me that if you had multiple assemblies (different versions) of the MVC types like ActionResult loaded into your AppDomain, and the AsActionResult method returned one version and your MVC web app used a different version, that it might just bail out with a ToString. What version of ASP.NET MVC are you running? DotNetOpenAuth's AsActionResult method was compiled against the 1.0 RTM version of the MVC framework. If you're using ASP.NET MVC 2 (included with .NET 4.0), I could see this maybe being a problem.

我相信,如果将此代码段添加到MVC 2的web.config文件中,它将允许您使用DotNetOpenAuth的官方版本,因此您不必自己构建:

I believe if you add this snippet to your MVC 2's web.config file, that it will allow you to use the official build of DotNetOpenAuth so you don't have to build your own:

<runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
        <dependentAssembly>
            <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
            <bindingRedirect oldVersion="1.0.0.0" newVersion="2.0.0.0" />
        </dependentAssembly>
    </assemblyBinding>
</runtime>

这篇关于使用ToString()的ActionResult重定向渲染的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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