diff options
author | Andrew Arnott <andrewarnott@gmail.com> | 2012-02-02 19:55:29 -0800 |
---|---|---|
committer | Andrew Arnott <andrewarnott@gmail.com> | 2012-02-02 19:55:29 -0800 |
commit | c1c763ef7ae943c7945c6d75459d02613329dd44 (patch) | |
tree | 3b39d9b629fc2435813fb666ad2e8bbb025714bf /samples/OAuthServiceProvider/Default.aspx.cs | |
parent | 492f4566b70142e5fc41a9c3fb4564c64c66ac5f (diff) | |
download | DotNetOpenAuth-c1c763ef7ae943c7945c6d75459d02613329dd44.zip DotNetOpenAuth-c1c763ef7ae943c7945c6d75459d02613329dd44.tar.gz DotNetOpenAuth-c1c763ef7ae943c7945c6d75459d02613329dd44.tar.bz2 |
Added OAuth 1.0 samples from v3.4 branch and fixed them up a bit so that
they work here.
Fixes #64
Diffstat (limited to 'samples/OAuthServiceProvider/Default.aspx.cs')
-rw-r--r-- | samples/OAuthServiceProvider/Default.aspx.cs | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/samples/OAuthServiceProvider/Default.aspx.cs b/samples/OAuthServiceProvider/Default.aspx.cs new file mode 100644 index 0000000..653046a --- /dev/null +++ b/samples/OAuthServiceProvider/Default.aspx.cs @@ -0,0 +1,49 @@ +namespace OAuthServiceProvider { + using System; + using System.Collections.Generic; + using System.Configuration; + using System.IO; + using System.Linq; + using System.Web; + using OAuthServiceProvider.Code; + + public partial class _Default : System.Web.UI.Page { + protected void createDatabaseButton_Click(object sender, EventArgs e) { + string databasePath = Path.Combine(Server.MapPath(Request.ApplicationPath), "App_Data"); + if (!Directory.Exists(databasePath)) { + Directory.CreateDirectory(databasePath); + } + string connectionString = ConfigurationManager.ConnectionStrings["DatabaseConnectionString"].ConnectionString.Replace("|DataDirectory|", databasePath); + var dc = new DataClassesDataContext(connectionString); + if (dc.DatabaseExists()) { + dc.DeleteDatabase(); + } + try { + dc.CreateDatabase(); + + // Fill with sample data. + dc.OAuthConsumers.InsertOnSubmit(new OAuthConsumer { + ConsumerKey = "sampleconsumer", + ConsumerSecret = "samplesecret", + }); + dc.Users.InsertOnSubmit(new User { + OpenIDFriendlyIdentifier = "=arnott", + OpenIDClaimedIdentifier = "=!9B72.7DD1.50A9.5CCD", + Age = 27, + FullName = "Andrew Arnott", + FavoriteSites = new System.Data.Linq.EntitySet<FavoriteSite> { + new FavoriteSite { SiteUrl = "http://www.microsoft.com" }, + new FavoriteSite { SiteUrl = "http://www.google.com" }, + }, + }); + + dc.SubmitChanges(); + this.databaseStatus.Visible = true; + } catch (System.Data.SqlClient.SqlException ex) { + foreach (System.Data.SqlClient.SqlError error in ex.Errors) { + Response.Write(error.Message); + } + } + } + } +}
\ No newline at end of file |