1.先修改你的web.config:
<authentication mode="Windows"/> 
-->>>
<authentication mode="Forms"/>

解决方案 »

  1.   

    FormsIdentity identity = 
             (FormsIdentity)application.Context.User.Identity;
    还有,我不知道你的登录页面如何写的
      

  2.   

    运行时报错这是错误“/ifilter”应用程序中的服务器错误。
    --------------------------------------------------------------------------------未将对象引用设置到对象的实例。 
    说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。 异常详细信息: System.NullReferenceException: 未将对象引用设置到对象的实例。源错误: 
    行 37:  HttpResponse response = application.Context.Response;
    行 38: 
    行 39:  WindowsIdentity identity = 
    行 40:  (WindowsIdentity)application.Context.User.Identity;
    行 41: 
     源文件: c:\inetpub\wwwroot\ifilter\userlogmodule.cs    行: 39 堆栈跟踪: 
    [NullReferenceException: 未将对象引用设置到对象的实例。]
       UserLogModule.OnAuthentication(Object sender, EventArgs a) in c:\inetpub\wwwroot\ifilter\userlogmodule.cs:39
       System.Web.SyncEventExecutionStep.System.Web.HttpApplication+IExecutionStep.Execute() +60
       System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +87 
    --------------------------------------------------------------------------------
    版本信息: Microsoft .NET Framework 版本:1.1.4322.573; ASP.NET 版本:1.1.4322.573
      

  3.   

    不知楼主的配置是否有<authorization>配置节点?
      

  4.   

    application不会为空,application.Context也不会为空,application.Context.User.Identity为空不会出错,所以如果是这句出错的话那只有application.Context.User为空了。
      

  5.   

    有啊配置<authorization>配置节点<authentication mode="Forms"/>
      

  6.   

    application.Context.User为空了。是啊但怎么解决啊
      

  7.   

    <authentication -->>认证
    <authorization -->>授权
      

  8.   

    把你的Web.Config中的内容修改如下:
    <authentication mode="Windows"/> 
    改为 
    <authentication mode="Forms"/>
      

  9.   

    修改你的web.config:
    <authentication mode="Windows"/> 
    -->>>
    <authentication mode="Forms"/>
      

  10.   

    我再次说我已修改<authentication mode="Forms"/>
      

  11.   

    application.Context.User为空了。是啊但怎么解决啊=======================================================================
    哎?~~~~~~~~~
    我有空,我来回答好了~
    这是因为你并没有将用户登陆信息注册进cookies中去~~application.Context.User其实是自动将信息从cookies中提取出来再初始化Principal的~
    这个地方确实很多人不理解~但是,不管它,这是ASP.NET自动处理的正确的方法是在用户登陆时执行一个步骤
    事先声明,这个步骤可以用SaveAuthCookie() GetAutoCookie() RedirecrFromLoginName()等多种方式解决,最主要的一点就是一定要将特定信息存到Cookie中去
    简单验证的方法1
    if (验证通过)
    System.Security.FormsAuthentication.SetAutoCookie(UserName,false);方法2
    if (验证通过)
    HttpCookie authenticationCookie=FormsAuthentication.GetAutoCookie(UserName,false);
    Response.Cookies.Add(authenticationCookie);复杂的方法比如需要保存自定义的用户信息,需要自定义实现IPrincipal和IIdentity
    然后判断Context.User的类型是否为你定义的类型
    如果不是,就利用User.Name保存的用户唯一标示来初始化建立你自己的类型的Principal和Identity类,然后
    Context.User=yourPrincipal;
    一切OK了~~如果还有问题,请去书店购买asp.net安全性高级编程