Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/78.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 使用jquery对windows用户进行身份验证_Asp.net_Jquery_Web Services - Fatal编程技术网

Asp.net 使用jquery对windows用户进行身份验证

Asp.net 使用jquery对windows用户进行身份验证,asp.net,jquery,web-services,Asp.net,Jquery,Web Services,我的主页 <head runat="server"> <script type="text/javascript"> $(document).ready(function() { var userName = '<%# System.Web.HttpContext.Current.Request.ServerVariables["AUTH_USER"].ToString() %>'; alert(userNa

我的主页

<head runat="server">
    <script type="text/javascript">

    $(document).ready(function() {

        var userName = '<%# System.Web.HttpContext.Current.Request.ServerVariables["AUTH_USER"].ToString() %>';
        alert(userName);
        $.ajax({ type: "POST",
            url: "DemoWebService.asmx/GetFulName",
            contentType: "application/json; charset=utf-8",
            dataType: "xml",
            dataType: "json",
            data: "{'networkId':'" + userName + "'}",
            processData: false,
            error: function(XMLHttpRequest, textStatus, errorThrown) { ajaxError(XMLHttpRequest, textStatus, errorThrown); },
            success: function(xml) { ajaxFinish(xml); }
        });

    });
  </script>
</head>
既然我在母版页上检查,那么存储身份验证结果的最佳实践是什么,这样我就不必检查每个页面了。在使用jquery之前,我将其存储在会话中

谢谢

web.config

<authentication mode="Windows"/>
<webServices>
<protocols>
  <add name="HttpPost"/>
  <add name="HttpGet"/>
</protocols>
</webServices>

您可以将结果存储在cookie中,然后在后续页面上检查该cookie以获取登录的用户名。如果用户注销或其身份验证会话过期,您需要确保并删除cookie


有一个支持读取/写入/删除cookie的方法。

您可以将结果存储在cookie中,然后在后续页面上检查该cookie以获取登录的用户名。如果用户注销或其身份验证会话过期,您需要确保并删除cookie

有一个支持读取/写入/删除cookie的方法

<authentication mode="Windows"/>
<webServices>
<protocols>
  <add name="HttpPost"/>
  <add name="HttpGet"/>
</protocols>
</webServices>