你好,我希望你能帮助我。我正在用asp.net语言开发一个窗口身份验证。问题是它可以工作,当我进入页面时,我得到了登录用户的名称。
问题是当我将我的页面上传到 IIS 时,登录用户的名称不会出现,但我希望你能从 IIS 中帮助我。
因为当我从我的源代码运行它对我有用但是当我将它上传到 IIS 时我没有得到登录窗口的用户名我得到
DefaultAppPol
请有人可以帮助我。我已经尝试了一切,但我无法摆脱
如果可能的话,他们可以帮助我。
唯一的问题是当我进入 IIS
HTML登录。
<%
string strHostName = System.Net.Dns.GetHostName();
string clientIPAddress = System.Net.Dns.GetHostAddresses(strHostName).GetValue(1).ToString();
//txtIp.Text = (clientIPAddress);
txtUsuario.Text = System.Environment.UserName;
%>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0" />
<title>.:: Sistema de Usuarios | FINANCIERA QAPAQ S.A. ::.</title>
<link rel="stylesheet" type="text/css" href="css/bootstrap.min.css" />
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/meyer-reset/2.0/reset.min.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/meyer-reset/2.0/reset.min.css">
<link rel="stylesheet" href="css/style4.css">
<!-- Optional theme -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css" integrity="sha384-rHyoN1iRsVXV4nD0JutlnGaslCJuC7uwjduW9SVrLvRYooPp2bWYgmgJQIXwl/Sp" crossorigin="anonymous">
<!-- Latest compiled and minified JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
</head>
<script type="text/javascript">
var usuario = document.getElementById('<%=txtUsuario.ClientID%>');
usuario.readOnly = true;
</script>
<body>
<center>
<form id="form1" runat="server" method="post">
<div class="group">
<asp:TextBox ID="txtUsuario" runat="server" Width="250px" MinLines="1" MaxLength="15" readonly CssClass="form-control" class="highlight" for="inputSuccess3" ></asp:TextBox>
<label></label>
</div>
<asp:Button runat="server" ID="btnLogin" Width="250px" Onclick="btnLogin_Click" CssClass="btn btn-danger" Text="Iniciar Session" />
</form>
</center>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script type="text/javascript" src="js/bootstrap.min.js"></script>
<script type="text/javascript" src="css/bootstrap.css"></script>
<script type="text/javascript" src="js/bootstrap.min.js"></script>
<script src='http://code.jquery.com/jquery-2.1.4.min.js'></script>
<script src='https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js'></script>
<script type="text/javascript" src="js/bootstrap.min.js"></script>
<script src='http://code.jquery.com/jquery-2.1.4.min.js'></script>
<script src='https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js'></script>
<script src="js/index4.js"></script>
</body>
</html>
网络配置。
<configuration>
<configSections>
<sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
<section name="DesbloqueoUsuario.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</sectionGroup>
</configSections>
<system.web>
<compilation debug="true" targetFramework="4.5" />
<httpRuntime targetFramework="4.5" />
</system.web>
<connectionStrings>
<add name="con" connectionString="server=10.0.101.85\instbdd01; database=Seguridad; user id=SA; password=SA123456789*;" providerName="System.Data.SqlClient"/>
<add name="conn" connectionString="server=10.0.101.85\instbdd01; database=BatCliente; user id=SA; password=SA123456789*;" providerName="System.Data.SqlClient"/>
</connectionStrings>
<applicationSettings>
<DesbloqueoUsuario.Properties.Settings>
<setting name="DesbloqueoUsuario_localhost_WebService" serializeAs="String">
<value>http://localhost:56117/WebService.asmx</value>
</setting>
<setting name="DesbloqueoUsuario_localhost1_WebService2" serializeAs="String">
<value>http://localhost:56116/WebService2.asmx</value>
</setting>
<setting name="DesbloqueoUsuario_localhost9_WebService3" serializeAs="String">
<value>http://localhost:56117/WebService3.asmx</value>
</setting>
</DesbloqueoUsuario.Properties.Settings>
</applicationSettings>
<system.serviceModel>
<bindings />
<client />
</system.serviceModel>
</configuration>
IIS 中的问题
当我在我的电脑上运行时
对于您正在考虑的情况,有几件事会影响操作。我将列出您应该检查的内容:
应用程序中的注意事项
确保 web.config 具有以下设置。
获取页面上的用户名(在 Web 项目中)
从另一个项目(例如 Web 项目引用的数据层)获取用户名
如果您使用 IIS Express 调试项目
确保 Windows 身份验证配置正确(必须禁用匿名身份验证,否则这将是应用程序将采用的默认模式,并且永远不会通过 Windows 进行身份验证)
如果项目要在 IIS Local 中执行
确保在 IIS 服务器上安装了“Windows 身份验证”功能。这是通过操作系统的“添加和删除程序”选项完成的
然后验证在您发布的“Web 应用程序”中正确配置了身份验证模式(出于与上述相同的原因,必须禁用匿名身份验证)
在您的
conectionString
添加Integrated Security=True;
中,如下所示:官方文档说:
或者在你的情况下,使用:
您可以尝试一方面使用:
此外,您应该记住,您需要在相应的应用程序中激活 Windows 身份验证。否则,有可能apppool本身的用户会带你。