Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/vb.net/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Asp.net httpContext用户标识_Asp.net_Vb.net_Iis_Httpcontext - Fatal编程技术网

Asp.net httpContext用户标识

Asp.net httpContext用户标识,asp.net,vb.net,iis,httpcontext,Asp.net,Vb.net,Iis,Httpcontext,我想根据用户身份限制用户对我网站的访问,我使用了以下代码它在Visual Studio中运行良好,但当我发布到IIS时,会将userIdentity=NULL发送到数据库 Dim httpContext__1 As HttpContext = HttpContext.Current Dim winIdentity As System.Security.Principal.WindowsIdentity = DirectCast(httpContext__1.User.Identity, Wind

我想根据用户身份限制用户对我网站的访问,我使用了以下代码它在Visual Studio中运行良好,但当我发布到IIS时,会将userIdentity=NULL发送到数据库

Dim httpContext__1 As HttpContext = HttpContext.Current
Dim winIdentity As System.Security.Principal.WindowsIdentity = DirectCast(httpContext__1.User.Identity, WindowsIdentity)
Dim userIdentity As String = winIdentity.Name

hasAccess = GetUserFromDB(userIdentity)
If hasAccess Then
    ' restrictions on 
Else
End If

我们需要确保Windows身份验证已启用,匿名身份验证已禁用。

您似乎将Visual Basic代码与Visual C#代码混合在一起。你在用一种新的语言写作吗?Visual BasiC#也许?:)嗨#VisualVincent我不是在创造新语言,只是写了伪代码,但看起来像C。因为你有实际的代码帖子,现在我已经用VB代码更新了:)我知道你不是在创造新语言,我只是在开玩笑,因为你似乎混合了这些语言。:)