-
Notifications
You must be signed in to change notification settings - Fork 3
/
Global.asax.cs
79 lines (67 loc) · 2.77 KB
/
Global.asax.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
using Microsoft.Owin;
using Microsoft.Owin.Security;
using Microsoft.Owin.Security.OpenIdConnect;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.SessionState;
namespace S3PWebUI
{
public class Global : System.Web.HttpApplication
{
protected void Application_Start(object sender, EventArgs e)
{
}
protected void Session_Start(object sender, EventArgs e)
{
}
protected void Application_BeginRequest(object sender, EventArgs e)
{
HttpContext.Current.Response.AddHeader("Access-Control-Allow-Origin", "*");
if (HttpContext.Current.Request.HttpMethod == "OPTIONS")
{
HttpContext.Current.Response.AddHeader("Access-Control-Allow-Methods", "GET, POST");
HttpContext.Current.Response.AddHeader("Access-Control-Allow-Headers", "Content-Type, Accept");
HttpContext.Current.Response.AddHeader("Access-Control-Max-Age", "17280000");
HttpContext.Current.Response.End();
}
}
//protected void Application_AcquireRequestState(object sender, EventArgs e)
//{
// if (!Request.IsAuthenticated)
// {
// if (Request.Url.ToString().Contains("LoginRequird.aspx?returnurl="))
// {
// string returnUrl = Request.Url.ToString().Substring(Request.Url.ToString().IndexOf("=") + 1);
// HttpContext.Current.GetOwinContext().Authentication.Challenge(
// new AuthenticationProperties { RedirectUri = returnUrl }, OpenIdConnectAuthenticationDefaults.AuthenticationType
// );
// }
// else
// {
// HttpContext.Current.GetOwinContext().Authentication.Challenge(
// new AuthenticationProperties { RedirectUri = Request.Url.AbsoluteUri }, OpenIdConnectAuthenticationDefaults.AuthenticationType
// );
// }
// }
//}
//protected void Application_AuthenticateRequest(object sender, EventArgs e)
//{
// if (!Request.IsAuthenticated && Request.Url.ToString().Contains("S3PDataService.svc") && !Request.Url.ToString().Contains("returnurl="))
// {
// HttpContext.Current.Response.Redirect("~/LoginRequird.aspx?returnurl=" + Request.Url.ToString());
// }
//}
protected void Application_Error(object sender, EventArgs e)
{
}
protected void Session_End(object sender, EventArgs e)
{
}
protected void Application_End(object sender, EventArgs e)
{
}
}
}