在ASP.net和C#中 - 在我的pageLoad事件中,我点击了一个按钮,该按钮编写了代码以获取SSO链接,然后使用RegisterStartUpScript添加一个window.open,其中包含指向SSO的链接。
在SSO打开并加载后,我想将带有pageLoad事件的页面重定向到另一个页面。
在下面的代码中,autoOpenSSO和redirectUser是在管理界面中加载的设置。
问题:当autoOpenSSO为true并且我将redirectUser设置为false时,弹出窗口打开没有问题,但是当我将重定向设置为true时,弹出窗口没有打开,页面重定向回我的重定向地址
我希望弹出窗口打开,页面重定向回我的重定向页面,但感觉我错过了什么,并且没有任何运气搜索。
我的代码:
protected void Page_Load(object sender, EventArgs e)
{
if (autoOpenSSO == true)
{
ccdetails_Click(this, null);
}
if (redirectUser == true)
{
Response.Redirect(redirectAddress);
}
}
protected void ccdetails_Click(object sender, EventArgs e)
{
ClientScriptManager cs = Page.ClientScript;
try
{
string link = getSSOlink(ah1.InstitutionUserID, cardnumber).Trim();
string s = "window.open('" + link + "','_blank', 'width=980,height=600,resizable=yes');";
cs.RegisterStartupScript(this.GetType(), "PopupScript", s, true);
}
catch (Exception se)
{
LogSystem.LogInfo(se.ToString());
}
}
任何想法都表示赞赏。
答案 0 :(得分:0)
我所要做的就是在我的注册启动脚本中添加另一行js,重定向到我想要的页面。修改后的代码可以在下面找到。我的页面上有设置,允许我决定是否要在SSO打开后自动打开SSO并自动重定向用户,这是s = s + t部分的目的。
protected void Page_Load(object sender, EventArgs e)
{
if (autoOpenSSO == true)
{
ccdetails_Click(this, null);
}
}
protected void ccdetails_Click(object sender, EventArgs e)
{
ClientScriptManager cs = Page.ClientScript;
try
{
string link = getSSOlink(ah1.InstitutionUserID, cardnumber).Trim();
string s = "var popupWindow = window.open('" + link + "','_blank', 'width=980,height=600,resizable=yes');";
string t = "window.location.replace('" + redirectAddress + "')";
if (redirectUser == true)
{
s = s + t;
}
cs.RegisterStartupScript(this.GetType(), "PopupScript", s, true);
}
catch (Exception se)
{
LogSystem.LogInfo("Access issue - " + se.ToString());
}
}