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>