申请教程,以OpenID的支持添加到NerdDinner范例ASP.NET MVC应用程序 [英] Request for Tutorial to add Openid Support to NerdDinner ASP.NET MVC application

查看:163
本文介绍了申请教程,以OpenID的支持添加到NerdDinner范例ASP.NET MVC应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找了解ASP.NET MVC和OpenID使用ASP.NET MVC的NerdDinner教程。

I'm looking learn about ASP.NET MVC and OpenId using the ASP.NET MVC NerdDinner tutorial.

我想换成身份验证系统的NerdDinner中唯一的OpenID。我已经下载了最新的DotNetOpenAuth库,但我不知道如何把它放在一起。任何人都可以快速的一步一步的教程帮助?

I would like to replace the Authentication system in NerdDinner to be OpenId only. I've downloaded the latest DotNetOpenAuth libraries but I'm not sure how to put it all together. Can anyone help with a quick step-by-step tutorial?

如跌落在图书馆还是有需要的应用,以及显著的变化是如此简单?

Is this as simple as dropping in the library or are there significant changes needed to the application as well?

推荐答案

一旦你下载 dotnetopenid ,看样品\\ RelyingPartyMvc目录中。有一个地方,他们更换OpenID的默认MVC认证系统的样本。有关code为控制器/ UserController.cs。这里是身份验证操作:

Once you download dotnetopenid, look in the samples\RelyingPartyMvc directory. There is a sample where they replace the default MVC authentication system with OpenID. The relevant code is in Controllers/UserController.cs. Here is the Authenticate action:

//Stage 1: Show form asking for Open ID identifier URL
var openid = new OpenIdRelyingParty();
if (openid.Response == null) {
	// Stage 2: user submitting Identifier
	Identifier id;
	if (Identifier.TryParse(Request.Form["openid_identifier"], out id)) {
			openid.CreateRequest(Request.Form["openid_identifier"]).RedirectToProvider();
	} else {
			ViewData["Message"] = "Invalid identifier";
			return View("Login");
			}
} else {
	// Stage 3: OpenID Provider sending assertion response
	switch (openid.Response.Status) {
		case AuthenticationStatus.Authenticated:
			FormsAuthentication.RedirectFromLoginPage(openid.Response.ClaimedIdentifier, false);
			break;
		case AuthenticationStatus.Canceled:
			ViewData["Message"] = "Canceled at provider";
			return View("Login");
		case AuthenticationStatus.Failed:
			ViewData["Message"] = openid.Response.Exception.Message;
			return View("Login");
	}
}
return new EmptyResult();

这篇关于申请教程,以OpenID的支持添加到NerdDinner范例ASP.NET MVC应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆