I have been trying out the DotNetOpenAuth samples with ASP.Net MVC 4 Developer Preview.
I can successfully invoke my Action from my test page, but run into a strange issue because of one line of code:
var request = _openid.CreateRequest(openIdUrl);
var fetch = new FetchRequest();
fetch.Attributes.AddRequired(WellKnownAttributes.Contact.Email);
fetch.Attributes.AddRequired(WellKnownAttributes.Name.First);
fetch.Attributes.AddRequired(WellKnownAttributes.Name.Last);
request.AddExtension(fetch);
//return RedirectToAction("Login");
return request.RedirectingResponse.AsActionResult(); // <-- This is the line throwing the error
If I comment out the offending line of code and uncomment the one before this, I do not see the runtime error anymore.
So far I have tried:
1) Ensuring that I have the correct redirects:
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Web.Helpers" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0" newVersion="2.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0" newVersion="2.0.0.0" />
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
</dependentAssembly>
</assemblyBinding>
<legacyHMACWarning enabled="0" />
</runtime>
2) Have the correct namespaces:
using DotNetOpenAuth.OpenId.Extensions.AttributeExchange;
using DotNetOpenAuth.OpenId.Extensions;
It seems to me that the DotNetOpenAuth dll was compiled against MVC V 1.0.0 and the binding redirect is either not working or the extension method was maybe working against a deprecated method.
MVC Version: 4.0.0.0 DotNetOpenAuth Version: 3.4.7.11121
Any help on getting this working with MVC 4 would be greatly appreciated. The MVC error screen image is further below:
Update I found that AsActionResult is the cause of the issue, maybe because the extension method is not compatible with .Net 4.0. I can get the OutgoingWebResponse object from request.RedirectingResponse but do know how to cast it to an ActionResult