是B/S结构,在公司内部使用,需要用户输入系统的地址,这个地址没有用户名和密码输入,页面载入时获取到用户登录windows的用户名
现在的情况是:Request.ServerVariables["LOGON_USER"],在匿名访问时为空字符串。
要正常使用必须在IIS里选windows验证,可这样一来总是弹出那个验证输入框。能否去掉这个登录框?

解决方案 »

  1.   

    我这个不可以吗,我用怎么可以???
    WindowsIdentity       winId       =       (WindowsIdentity)HttpContext.Current.User.Identity;   
    WindowsImpersonationContext       ctx       =       null;   
    try   
    {   
                                    ctx       =       winId.Impersonate();   
                    WindowsIdentity.GetCurrent().Name 
                    }   
    catch   
    {   
    }   
    finally   
    {   
                    //       Revert       impersonation.   
                    if       (ctx       !=       null)   
                                    ctx.Undo();   

      

  2.   

    不取消匿名登录的话仍然得到空字符串 
    使用windows登录会弹出来那个对话框(在客户端试就会弹出来)......