我有一文件a.aspx,运行时动态加载 b.ascx 或c.ascx 中的一个用户文件
而b.ascx文件需要用户登陆身份验证后才能访问,c.asxc文件不需要用户登陆即可访问
请问如何在web.config中配置?

解决方案 »

  1.   

    在a.aspx.cs里判断权限,然后显示c.ascx或者不显示.
      

  2.   

    在a.aspx.cs的page_load里写入判断,或者在某个事件的处理函数里写入判断显示b.ascx
      

  3.   

    直接在web.config里配置forms验证有无办法?
      

  4.   

    你也可以在web.config里试试,我没这么做过,但我觉得应该可以.
      

  5.   

    试试看下端代码
    <location path="b.ascx">
    <system.web>
    <authorization>
    <deny users="?"/>
    </authorization>
    </system.web>
      

  6.   

    to web_gus(penny)
    -------------------
    <location path="b.ascx">
    <system.web>
    <authorization>
    <deny users="?"/>
    </authorization>
    </system.web>
    ---------------
    也不行
      

  7.   

    >>>运行时动态加载web.config does not work on ascx files, just do, in Page_Load, for exampleif (HttpContext.Current.User.Identity.IsAuthenticated)
    {
       Control c = LoadControl("b.ascx");
       //cast to the right class if you need to set some properties
       form1.Controls.Add(c);
    }
      

  8.   

    在a.aspx.cs里判断 然后动态加载c.ascx
    在 web.config中应该不行  
      

  9.   

    思归的方法可以,当有一个缺点,不好定位
    最好使用placeholder控件if (HttpContext.Current.User.Identity.IsAuthenticated)
    {
       Control c = LoadControl("b.ascx");
       //cast to the right class if you need to set some properties
       placeholder1.Controls.Add(c);
    }