如何在ASP.NET中设置基本身份验证SAN SSL
各位 我有一个asmx web服务,在IIS 7中非常热门,只启用了基本身份验证 在处理SSL之前,我正在尝试在本地计算机上测试基本身份验证 使用以下代码进行测试时如何在ASP.NET中设置基本身份验证SAN SSL,asp.net,web-services,basic-authentication,Asp.net,Web Services,Basic Authentication,各位 我有一个asmx web服务,在IIS 7中非常热门,只启用了基本身份验证 在处理SSL之前,我正在尝试在本地计算机上测试基本身份验证 使用以下代码进行测试时 [TestMethod] public void TestMethod1() { MyCompanyExternalService.CClaim claim = new MyCompanyExternalService.CClaim(); claim.Airline =
[TestMethod]
public void TestMethod1()
{
MyCompanyExternalService.CClaim claim = new MyCompanyExternalService.CClaim();
claim.Airline = "AA";
claim.OrigCty = "MCO";
claim.PaxFN = "John";
claim.PaxLN = "Smith";
claim.FileRef = "DL123321";
claim.OrigDate = Convert.ToDateTime("1/1/2001");
claim.ClaimFor = MyCompanyExternalService.EReasonsForClaim.Pilferage;
claim.AirlineClaimStatus = "Open";
MyCompanyExternalService.wsMyCompanyImportSoapClient MyCompanyImportSoapClient
= new MyCompanyExternalService.wsMyCompanyImportSoapClient("wsMyCompanyImportSoap");
MyCompanyImportSoapClient.ClientCredentials.UserName.UserName = "My-PC\\chron";
MyCompanyImportSoapClient.ClientCredentials.UserName.Password = "********";
Assert.IsTrue(MyCompanyImportSoapClient.SubmitClaim(claim));
}
。。我收到以下错误:
HTTP请求未经授权
客户端身份验证方案“基本”。
接收到的身份验证标头
来自服务器的是“基本”
realm=“localhost””
innerexception:远程服务器
返回错误:(401)未经授权
这是我的app.config
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="wsMyCompanyImportSoap" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
useDefaultWebProxy="true">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<security mode="TransportCredentialOnly">
<transport clientCredentialType="Basic" realm="" />
</security>
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://localhost/MyCompany/MyCompanyWebServiceApp/wsMyCompanyImport.asmx"
binding="basicHttpBinding" bindingConfiguration="wsMyCompanyImportSoap"
contract="MyCompanyExternalService.wsMyCompanyImportSoap"
name="wsMyCompanyImportSoap" />
</client>
</system.serviceModel>
</configuration>
有人能发现我的问题吗?我正在使用几个管理员用户来测试web服务的基本身份验证。我不知道为什么,但他们失败了。最后,我尝试与一个测试用户进行身份验证,该测试用户除了web服务目录上的ACL之外没有任何权限,它成功了。请参考以下链接。这可能对你有帮助