首页 新闻 赞助 找找看

IIS6使用Form身份验证无效

0
悬赏园豆:50 [已关闭问题] 关闭于 2015-02-02 15:18

我在自己本地web.config使用

 <system.web>
        <compilation debug="true" targetFramework="4.0" />
      
      <authentication mode="Forms">
        <!--未登陆跳转至登陆页面 -->
        <forms name="mycook" loginUrl="login.htm" protection="All" path="/"/>
      </authentication> 
    </system.web>

 <location path="street0">
    <system.web>

      <authorization>

        <allow roles="admin"/>

        <deny users="*"/>      

      </authorization>
    </system.web>
  </location>

结合

自己添加的类Global.asax

中的

   protected void Application_AuthenticateRequest(object sender, EventArgs e)
        {
            if (HttpContext.Current.User != null)
            {

                if (HttpContext.Current.User.Identity.IsAuthenticated)
                {

                    if (HttpContext.Current.User.Identity is FormsIdentity)
                    {

                        FormsIdentity id = (FormsIdentity)HttpContext.Current.User.Identity;

                        FormsAuthenticationTicket tiecket = id.Ticket;

                        string userData = tiecket.UserData;

                        string[] roles = userData.Split(',');

                        HttpContext.Current.User = new System.Security.Principal.GenericPrincipal(id, roles);

                    }

                }

            }
        }

目的是想让street0下的页面是用户登陆后才可以访问的,如果没有登陆则跳转到login.htm页面.我在自己本机运行效果是达到了!但是使用IIS发布的网站是没有效果的,百度了下,说是IIS要使用Form身份登陆,但是IIS中没有此选项!

电脑操作系统是 ,IIS版本是IIS6.0

求大神搭救......文字说明或图解!我感觉就是IIS中的配置原因!

答案好,追加分数!

问题补充:

登陆成功后做的代码忘记贴出来了,如下

 

IIS身份配置

金正声的主页 金正声 | 初学一级 | 园豆:41
提问于:2013-10-30 15:43
< >
分享
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册