summaryrefslogtreecommitdiffstats
path: root/samples/RelyingPartyWebForms/Global.asax.cs
diff options
context:
space:
mode:
authorAndrew Arnott <andrewarnott@gmail.com>2009-01-31 21:32:01 -0800
committerAndrew <andrewarnott@gmail.com>2009-01-31 21:32:01 -0800
commite865ec7da293496d6c2e67039b86c4ef9ded5a6c (patch)
tree116d6a4e8c0892d2be13acd31bacae004de4bb8b /samples/RelyingPartyWebForms/Global.asax.cs
parentf6d5493a42d07389421763c2f1da35b4ca7d9f45 (diff)
downloadDotNetOpenAuth-e865ec7da293496d6c2e67039b86c4ef9ded5a6c.zip
DotNetOpenAuth-e865ec7da293496d6c2e67039b86c4ef9ded5a6c.tar.gz
DotNetOpenAuth-e865ec7da293496d6c2e67039b86c4ef9ded5a6c.tar.bz2
Added OpenID sample sites: RP MVC, RP WebForms, RP Classic ASP, OP WebForms.
Diffstat (limited to 'samples/RelyingPartyWebForms/Global.asax.cs')
-rw-r--r--samples/RelyingPartyWebForms/Global.asax.cs65
1 files changed, 65 insertions, 0 deletions
diff --git a/samples/RelyingPartyWebForms/Global.asax.cs b/samples/RelyingPartyWebForms/Global.asax.cs
new file mode 100644
index 0000000..91cfd9a
--- /dev/null
+++ b/samples/RelyingPartyWebForms/Global.asax.cs
@@ -0,0 +1,65 @@
+namespace RelyingPartyWebForms {
+ using System;
+ using System.Collections.Specialized;
+ using System.IO;
+ using System.Text;
+ using System.Web;
+
+ public class Global : HttpApplication {
+ public static log4net.ILog Logger = log4net.LogManager.GetLogger(typeof(Global));
+
+ internal static StringBuilder LogMessages = new StringBuilder();
+
+ public static string ToString(NameValueCollection collection) {
+ using (StringWriter sw = new StringWriter()) {
+ foreach (string key in collection.Keys) {
+ if (key.StartsWith("__")) {
+ continue; // skip
+ }
+ sw.WriteLine("{0} = '{1}'", key, collection[key]);
+ }
+ return sw.ToString();
+ }
+ }
+
+ protected void Application_Start(object sender, EventArgs e) {
+ log4net.Config.XmlConfigurator.Configure();
+ Logger.Info("Sample starting...");
+ }
+
+ protected void Application_End(object sender, EventArgs e) {
+ Logger.Info("Sample shutting down...");
+
+ // this would be automatic, but in partial trust scenarios it is not.
+ log4net.LogManager.Shutdown();
+ }
+
+ protected void Application_BeginRequest(object sender, EventArgs e) {
+ // System.Diagnostics.Debugger.Launch();
+ Logger.DebugFormat("Processing {0} on {1} ", Request.HttpMethod, this.stripQueryString(Request.Url));
+ if (Request.QueryString.Count > 0) {
+ Logger.DebugFormat("Querystring follows: \n{0}", ToString(Request.QueryString));
+ }
+ if (Request.Form.Count > 0) {
+ Logger.DebugFormat("Posted form follows: \n{0}", ToString(Request.Form));
+ }
+ }
+
+ protected void Application_AuthenticateRequest(object sender, EventArgs e) {
+ Logger.DebugFormat("User {0} authenticated.", HttpContext.Current.User != null ? "IS" : "is NOT");
+ }
+
+ protected void Application_EndRequest(object sender, EventArgs e) {
+ }
+
+ protected void Application_Error(object sender, EventArgs e) {
+ Logger.ErrorFormat("An unhandled exception was raised. Details follow: {0}", HttpContext.Current.Server.GetLastError());
+ }
+
+ private string stripQueryString(Uri uri) {
+ UriBuilder builder = new UriBuilder(uri);
+ builder.Query = null;
+ return builder.ToString();
+ }
+ }
+} \ No newline at end of file