目前我正在开发一个使用DotNetOpenAuth CTP版本的OAuth2授权服务器。我的授权服务器在asp.net MVC3中,它基于库提供的示例。一切工作正常,直到应用程序达到用户授权客户端的地步。PrepareResponse()。AsActionResult()抛出不受支持的异常DotNetOpenAuth CTP
有我的OAuth控制器内部的作用,这需要授权过程的关怀,是非常相似的样品中的等效操作:
[Authorize, HttpPost, ValidateAntiForgeryToken]
public ActionResult AuthorizeResponse(bool isApproved)
{
var pendingRequest = this.authorizationServer.ReadAuthorizationRequest();
if (pendingRequest == null)
{
throw new HttpException((int)HttpStatusCode.BadRequest, "Missing authorization request.");
}
IDirectedProtocolMessage response;
if (isApproved)
{
var client = MvcApplication.DataContext.Clients.First(c => c.ClientIdentifier == pendingRequest.ClientIdentifier);
client.ClientAuthorizations.Add(
new ClientAuthorization
{
Scope = OAuthUtilities.JoinScopes(pendingRequest.Scope),
User = MvcApplication.LoggedInUser,
CreatedOn = DateTime.UtcNow,
});
MvcApplication.DataContext.SaveChanges();
response = this.authorizationServer.PrepareApproveAuthorizationRequest(pendingRequest, User.Identity.Name);
}
else
{
response = this.authorizationServer.PrepareRejectAuthorizationRequest(pendingRequest);
}
return this.authorizationServer.Channel.PrepareResponse(response).AsActionResult();
}
每次程序运行到这一行:
this.authorizationServer.Channel.PrepareResponse(response).AsActionResult();
系统抛出一个我没有研究过的异常。以下例外: LINQ to Entities仅支持无参数的构造函数和初始值设定项。
堆栈跟踪:http://pastebin.com/TibCax2t
我已经从不同的样品做的唯一的事情是,我使用实体框架的代码第一个方法,一个我认为样品是使用其自动生成实体设计师完成的。
预先感谢您。
你知道了吗?我遇到了同样的问题。 – fuzz 2012-04-21 06:04:38