I am overriding our global asax page where i want our users who are in a particular sharepoint list/ sharepoint group be redirected to the 2fa page (third party provided) every time the access sharepoint site. this is my code however i get a null reference exception error when i check the uls logs. this is a snippet of my code, this is the entry point:
public void Application_BeginRequest(object sender, EventArgs e)
{
//this.Context.Response.Redirect("https://www.google.com");
if (SPContext.Current.Web.IsCurrentUserMemberOfGroup(Convert.ToInt32(WebConfigurationManager.AppSettings.Get("2FAAdminGroup"))))
{
if (this.Context.Session["jwt"] == null)
{
this.Context.Session["jwt"] = "continue";
string text = SPContext.Current.Web.CurrentUser.LoginName;
if (text.Contains("\\"))
{
text = text.Substring(text.IndexOf("\\") + 1);
}
this.r1 = this.Status_Check(text);
if (string.IsNullOrEmpty(this.r1))
{
string url = this.Deregister_Check(text);
this.Context.Response.Redirect(url);
}
this.Context.Response.Redirect(this.r1);
}
else
{
string a = this.Context.Session["jwt"].ToString();
if (a == "continue")
{
string text2 = HttpContext.Current.Request.QueryString["jwt"];
if (text2 != null && text2 != "")
{
this.Context.Session["jwt"] = text2;
}
else
{
this.Context.Session["jwt"] = "continue";
string text = SPContext.Current.Web.CurrentUser.LoginName;
if (text.Contains("\\"))
{
text = text.Substring(text.IndexOf("\\") + 1);
}
this.r1 = this.Status_Check(text);
if (string.IsNullOrEmpty(this.r1))
{
string url2 = this.Deregister_Check(text);
this.Context.Response.Redirect(url2);
}
this.Context.Response.Redirect(this.r1);
}
}
}
}
}
basically what it first does is it gets the data from the web config. but i am getting errors on that part i think here "SPContext.Current.Web.IsCurrentUserMemberOfGroup(Convert.ToInt32(WebConfigurationManager.AppSettings.Get("2FAAdminGroup")))"
i am new to this so can somebody shed some light on what method to use for this?