开发者

ActionResult redirect renders using ToString()

Using the following sample: http://www.west-wind.com/We开发者_JAVA技巧blog/posts/899303.aspx

The following line...

return req.RedirectingResponse.AsActionResult();

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?

Thnx in advance!


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.

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>


Another solution, working for me with .Net 3.5 and MVC 2.

Instead of

var authRequest = relyingParty.CreateRequest(....);
....
return authRequest.RedirectingResponse.AsActionResult();

use

var authRequest = relyingParty.CreateRequest(....);
....
authRequest.RedirectToProvider();
Response.End();
return new EmptyResult();
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜