简体   繁体   English

使用Windows身份验证站点中托管的Web服务配置匿名访问

[英]Configure a web service w/ Anonymous Access hosted in a Windows Authentication site

I have an application on our intranet that is configured for Anonymous Authentication that needs to consume a web service configured for Windows Authentication. 我的Intranet上有一个配置为匿名身份验证的应用程序,该应用程序需要使用为Windows身份验证配置的Web服务。

I have added the following section to the web.config file to allow anonymous access on just the web service: 我已将以下部分添加到web.config文件中,以允许仅在Web服务上进行匿名访问:

<location path="services/MyApi.asmx">
    <system.web>
        <authorization>
            <allow users="?" />
        </authorization>
    </system.web>
</location>

When I try to consume the web service from the application with anonymous access, I get the following error: 当我尝试通过具有匿名访问权限的应用程序使用Web服务时,出现以下错误:

The request failed with HTTP status 401: Unauthorized. 请求失败,HTTP状态为401:未授权。

Here is my source code for consuming the web service: 这是我使用Web服务的源代码:

using (MyService.MyApi proxy = new MyService.MyApi())
{
    string employeeId = Session["EmpCode"].ToString();
    proxy.MyMethod(employeeId);
}

What do I need to do to resolve this error? 我需要怎么做才能解决此错误?

change ? 变化? for * in <allow users="*" /> it will be allow an Anonymous user to the webservice *<allow users="*" />这将是允许匿名用户web服务

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM