网站有一页面/fld/xxx.aspx,正常的访问路径是要先登陆后,现在我在网站外面任意写个htm文件....<form method=post action="/fld/xxx.aspx">....,我在
网站外面就可以访问这个页面了。请问有什么简单的方法就能屏蔽掉这种类似问题?(不想写代码,也不想用web.config)

解决方案 »

  1.   

    你肯定要写一个类然后每个页面调用他的权限 再看是否可以登陆访问呀,不写代码怎么可能实现哦 public static bool AdminUserSessionTimeOut()  //总后台判断用户是否登陆方法
           { 
               HttpContext p = HttpContext.Current; 
               if (p.Session["AUserName"] == null) 
              { 
                   //p.Response.Write("<div align='center'>未登陆或会话超时,请重新<a target='_self' href='../admin/Default.aspx'>登录</a>。</div>"); 
                   p.Response.Redirect("../Error/LoginError.htm");
                   p.Response.End(); 
                   return true; 
               } 
               return false;
           }
      

  2.   

    web.config或写代码任选一种
      不可能什么都不写就能进行验证
    3楼给出了代码,这是web.config配置文件 <authentication mode="Forms"> 
       
       <forms loginUrl="Login.aspx"></forms> 
       
      </authentication> 
       
      "Forms" 您为用户提供一个输入凭据的自定义窗体(Web 页),然后在您的应用程序中验证他们的身份。用户凭据标记存储在 Cookie 中。 
       
       <authorization> 
       
       <deny users="?" /> 
       
       </authorization> 
       
      deny表示禁止,users="?"表示匿名用户 
       
       <location path="NewUser.aspx"> 
       
       <system.web> 
       
       <authorization> 
       
       <allow users="*" /> 
       
       </authorization> 
       
       </system.web> 
       
       </location> 
      

  3.   

    通过session或cookie判断,不存在转向其他页面。或
    <customErrors mode="RemoteOnly" defaultRedirect="Error.aspx">
    </customErrors>
      

  4.   

    ...
    <allow users="xx,yy" /> 
    ....请问 xx,yy是登陆用户吗?如果是,那是不是要存放在.net能认识的表里啊?
      

  5.   

    写个BasePage让页面继承,如果SessionId没有权限就跳转页面
      

  6.   

    if (p.Session["AUserName"] == null) 
              { 
                   //p.Response.Write("<div align='center'>未登陆或会话超时,请重新<a target='_self' href='../admin/Default.aspx'>登录</a>。</div>"); 
                   p.Response.Redirect("../Error/LoginError.htm");
                   p.Response.End(); 
                   return true; 
               }