我现在有一个主页面(使用框架)index.aspx, 另外呢在该页面中使用了一些内容页面,比如body.aspx, top.aspx...等,现在我希望的效果是,不论用户匿名访问哪个页面(比如直接输入网址body.aspx),都将请求发送至登录界面,登录成功后则跳转到index.aspx。困难是:
1、如果直接使用FormAuthentication.RedirectFromLogin()方法,就会将body.aspx页面单独发给我(不会包含在框架中)。如果不使用FormAuthentication.RedirectFromLogin,改成Response.Redirect("index.aspx"),又会因为没有完成form验证重新跳回到登录界面。2、如果使用一般处理程序拦截用户对内容页面的访问,又担心显示框架页的时候也无法加载内容页部分。

解决方案 »

  1.   

    FormAuthentication验证完了返回Response.Redirect("index.aspx")啊也可以在 
    body.aspx里面写
    <script>
    if(self == window.top)
    window.top.location="index.aspx"
    </script>
      

  2.   

    请教孟哥,FormAuthentication验证如何做呢?,给个代码看看吧
      

  3.   


    //验证...
    if(success){
    FormsAuthentication.SetAuthCookie(userName,createPersistentCookie);
    Response.Redirect("index.aspx");
    }
    else
    {
    //...
    }
    ///SetAuthCookie 替换你的 RedirectFromLogin 
    ///参数没什么区别
    ///然后自己跳转
      

  4.   

    每个页面都写上JS:if( window.top == window.self ){
    alert('页面不是在框架中打开的');
    //导航到登陆页面
    }
      

  5.   

    我怎么才能让服务器确认用户是有效用户,这一段应该是在默认在FormAuthentication.RedirectFromLogin()完成的
      

  6.   


    要不然你重写membership的方法或者运行的时候判断 //js, global.asax.cs