I need help on a section of the code below to revise so instead of redirect to a full page I want it to redirect and open as a popup window. How can i change the code I have to make this possible.
void context_AcessDenied(object sender, EventArgs e)
{
try
{
HttpApplication httpApp = sender as HttpApplication;
HttpContext context = httpApp.Context;
string httpUrl = context.Request.Url.ToString();
string strSiteURL = string.Empty;
string strWebURL = string.Empty;
string strOwnerName = string.Empty;
string strOwnerEmail = string.Empty;
if (httpUrl.ToLower().Contains("/_layouts/accessdenied.aspx") && !httpUrl.ToLower().Contains("loginasanotheruser=true"))
{
strSiteURL = SPContext.Current.Web.Url;
SPSecurity.RunWithElevatedPrivileges(delegate()
{
using (SPSite site = new SPSite(strSiteURL))
{
using (SPWeb web = site.OpenWeb())
{
strWebURL = web.Url;
SPGroupCollection groups = web.Groups;
foreach (SPGroup group in groups)
{
if (group.Name.ToLower().Contains("owner") && !group.Name.ToLower().Contains("sub-owner") && group.Users.Count > 0)
{
SPUser owner = group.Users[0];
strOwnerName = owner.Name;
strOwnerEmail = owner.Email;
}
}
}
}
});
HttpContext.Current.Server.ClearError();
HttpContext.Current.Response.Clear();
//strCustomAcssDndURL = getAppSettingsValue(m_SiteCollCustAcsDndPG + "-" + strSiteURL);
//HttpContext.Current.Response.Redirect(strCustomAcssDndURL, false);
string redirect = getAppSettingsValue(m_SiteCollCustAcsDndPG);
redirect += "?ReqURL=" + strWebURL;
if (!string.IsNullOrEmpty(strOwnerEmail))
redirect += "&OwnEmail=" + strOwnerEmail;
if(!string.IsNullOrEmpty(strOwnerName))
redirect += "&OwnName=" + strOwnerName;
HttpContext.Current.Response.Redirect(redirect, false);
}
}
catch (Exception ex)
{
//Do your exception handling
HttpContext.Current.Server.ClearError();
HttpContext.Current.Response.Clear();
HttpContext.Current.Response.Redirect("/Pages/AccessDeniedOverride.aspx?Error=true&Message=" + ex.Message);
}
}