【问题标题】:redirecting parent page after session expires C#会话到期后重定向父页面C#
【发布时间】:2013-11-18 16:30:51
【问题描述】:

如果用户 ID 不存在,我正在编写与将页面重定向到登录屏幕直接相关的一段代码。

代码目前写成:

this.currentContext = System.Web.HttpContext.Current;
this.User = new BLL.User(); // base constructor
this.User.RestoreSession(currentContext.Session); // attempt to connect to DB with current session

if (this.UserID < 1)
{
    currentContext.Response.Redirect("~/Default.aspx?url=" + currentContext.Request.Url.AbsoluteUri.ToBase64());
}

哪个工作还不错。

然而,在一个新的插件中,我们正在构建它使用 iframe 的系统,这没关系,但登录屏幕发生在 iframe 中,我们需要让父窗口重定向到登录窗口,然后重定向回我们所在的页面。

我的问题是在不重写整个登录过程的情况下最好的方法是什么?

【问题讨论】:

    标签: c# redirect iframe httpcontext response.redirect


    【解决方案1】:

    在不重写登录过程的情况下进行重定向的最佳方法是用 Ajax 调用替换 iframe。检查这个:How can I use AJAX as an alternative to an iframe?

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-06-04
      • 2014-09-01
      • 1970-01-01
      相关资源
      最近更新 更多