Monday, 13 February 2012

Using DotNetOpenAuth and getting "DotNetOpenAuth.Messaging.OutgoingWebResponseActionResult"

Today I started integrating OpenID into my latest web application. I chose to use the DotNetOpenAuth library as a helper, it's top and makes Open ID really easy, supports Web Forms, MVC and even classic ASP. Anyhow there are many how too guides, including one from my good friend Danny Tuppeny, so when it comes to setting it up I refer you to those.

However today I found when I was using the AsActionResult extension method my web page would come back blank with just  DotNetOpenAuth.Messaging.OutgoingWebResponseActionResult written on screen. For some reason the ToString was being called and returned.

Commonly it seems that the issue is caused by not having a binding redirect for older versions of the MVC assembly however my one was set, but what I did notice was the following:

<dependentAssembly>
        <assemblyIdentity name="DataAnnotationsExtensions" publicKeyToken="358a5681c50fd84c" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-1.0.1.0" newVersion="1.0.1.0" />
        <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="1.0.0.0" newVersion="2.0.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
      </dependentAssembly>
The  DataAnnotationsExtensions also had an assemblyIdentity reference to MVC and this was set to version 2. But I was using MVC 3, so I believe what is happening is that the assembly redirect is looking at the first option and then using the wrong version.
I simply removed this redirect and let the main one be used and everything kicked back in.
A lesson learned :)

No comments:

Post a Comment