i’m trying to set up my code to request some attributes from the OpenID Service Provider. At the same time, I wish to return an ActionResult.
Here’s the code in the OpenId sample MVC project (that comes straight out of the DotNetOpenId / DotNetOpenAuth website) …
try
{
return openid.CreateRequest(Request.Form["openid_identifier"])
.RedirectingResponse
.AsActionResult();
}
catch (ProtocolException ex)
{ ... }
This is great, but it doesn’t show me requesting any optional or required attributes.
So, I’ve tried the following (my own, untested pseduo-ish code) ….
var fetch = new FetchRequest();
fetch.Attributes.AddRequired(WellKnownAttributes.Contact.Email);
fetch.Attributes.AddRequired(WellKnownAttributes.Name.FullName);
fetch.Attributes.AddRequired(WellKnownAttributes.Name.Alias);
fetch.Attributes.AddRequired(WellKnownAttributes.Preferences.Language);
fetch.Attributes.AddRequired(WellKnownAttributes.Preferences.TimeZone);
fetch.Attributes.AddRequired(WellKnownAttributes.Person.Gender);
openId.CreateRequest(identifier.ToString()).AddExtension(fetch);
This also seems fine. But … i don’t know how to now ask for the result to be an ActionResult()…
How can i create an openId.CreateRequest that allows me to define some required attributes AND return an ActionView ?
You’re doing great. Just combine the two approaches.
After you call
IAuthenticationRequest.AddExtensionall you want, just callIAuthenticationRequest.RedirectingResponse.AsActionResult().