2017-03-07 186 views
1

这是Default.aspx文件Windows身份验证在本地系统

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs"Inherits="Default"%> 

<!DOCTYPE html> 

<html xmlns="http://www.w3.org/1999/xhtml"> 
<head runat="server"> 
<title></title> 
</head> 
<body> 
<form id="form1" runat="server"> 
<div> 
Welcome to sample website:) 
</div> 
</form> 
</body> 
</html> 

这是web.config文件

<?xml version="1.0"?> 
<configuration> 
<system.web> 
<authentication mode="Windows"/> 
<identity impersonate="true"/> 
<compilation debug="true" targetFramework="4.5" /> 
<httpRuntime targetFramework="4.5" /> 
</system.web> 
<system.webServer> 
<validation validateIntegratedModeConfiguration="false"/> 
</system.webServer> 
</configuration> 

我无法获得Windows身份验证,我做了必要的修改也在applicationhost.config文件中。很好地帮助我如何继续前进。

回答

0

您的web.config配置不完整。

参见:Enabling Windows Authentication within an Intranet ASP.NET Web application

中也有很多其他的指南/博客文章上设置Windows身份验证asp.net如果你只是搜索互联网。

你还没有告诉ASP.NET拒绝匿名用户,这就是为什么你没有得到登录提示。

<configuration> 
    <system.web> 
     <authentication mode="Windows" /> 
     <authorization> 
      <deny users="?"/> 
     </authorization> 
    </system.web> 
</configuration> 

请注意以上 段内的指令是什么告诉ASP.NET拒绝访问应用程序 所有“匿名”用户在网站(“?”字符表示 匿名用户)。这迫使Windows对用户进行身份验证,并且 确保用户名始终可以从服务器上的代码获得。