views:

317

answers:

2

Using the following sample: http://www.west-wind.com/Weblog/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!

+1  A: 

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>
Andrew Arnott
This could be the case indeed! Will try it asap!
promontis
I've changed the reference to MVC 2. Initially, I got an exception saying that the signing was invalid, so I removed it. I now get the following error (which seems a lot better then the previous result):Must use the rewriter when using Contract.Requires<TException>at ContractHelper.TriggerFailureImplementation(ContractFailureKind kind, String displayMessage, String userMessage, String conditionText, Exception innerException)at ContractHelper.TriggerFailure(ContractFailureKind kind, String displayMessage, String userMessage, String conditionText, Exception innerException) ...
promontis
This error is because of the following: http://social.msdn.microsoft.com/Forums/en/codecontracts/thread/8f2a5842-7e18-42bf-b550-a30eb4c52817So, basically, DotNetOpenAuth can't target MVC 2?
promontis
So you were targeting MVC 2. MVC 1 ought to automatically retarget to MVC 2. But the presence of any MVC 1 assemblies might break that. Can you make sure you don't have any MVC 1 assemblies lying around in your web site's Bin folder?
Andrew Arnott
DNOA can target MVC 2 no problem. But you have to have Code Contracts installed when you build DNOA -- otherwise you won't get a build break but the runtime won't work for the reason you gave. It's not MVC2, it's that Code Contracts must run ccrewrite on the generated assembly.
Andrew Arnott
To conclude this SO question: Andrew was spot on with the MVC version. I've recompiled his source targetting MVC2 and using the latest install of code contracts. Keep in mind to replace the MVC1 library assemblies in his lib with MVC2, because it seems code contracts will still use those instead of MVC2 (even if it is set correctly in your solution). Kudos to Andrew!
promontis
I've edited my answer to include a web.config snippet
Andrew Arnott
I can confirm that DNOA works with MVC2 without a rebuild with the web.config piece. But if you want to compile against the Mvc Source it won't compile.
MvcCmsJon
Could be there another reason for this message? I'm using the prebuild DNOA v3.4.3, .NET 3.5 SP1 with MVC2 and VS2010.Before I upgraded the project to VS2010, I hadn't this problem.
EricSch
EricSch, you haven't mentioned making the web.config change. Did you do that?
Andrew Arnott
A: 

Any chance of someone having a DNOA build against MVC2 yet?

MvcCmsJon