【问题标题】:Visual Studio 2005 - Add webreference fails for secured webserviceVisual Studio 2005 - 为安全的 Web 服务添加 Web 引用失败
【发布时间】:2008-12-14 22:17:06
【问题描述】:

我在需要表单身份验证的目录中有一个 web 服务(asmx 文件)

当我尝试通过 VS2005 添加 WebReference 时 - 我收到以下错误:

The request failed with the error message:
--
<html><head><title>Object moved</title></head><body>
<h2>Object moved to <a href="/webchat/login.aspx?ReturnUrl=%2fwebchat%WebService.asmx">here</a>.</h2>
</body></html>

当我删除该目录中的 web.config(并且基本上删除了对表单身份验证的要求)时,一切正常。我可以添加 WebReference。

有什么想法吗?

【问题讨论】:

    标签: asp.net web-services forms-authentication


    【解决方案1】:

    将以下代码放入您的 web.config:

    <location path="path/to/your/service.asmx">
        <system.web>
            <authorization>
                <allow users="*"/>
            </authorization>
        </system.web>
    </location>
    

    ASP.Net 允许覆盖特定位置的应用程序范围的设置。

    【讨论】:

    • 谢谢它的工作。但是有没有一种方法可以在保持授权要求的同时将其用作网络参考?
    • AFAIK,不可能对 Web 服务使用相同的表单身份验证。您应该使用其他类型的身份验证来保护您的 Web 服务。看看这篇文章:code-magazine.com/…
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-01-12
    • 1970-01-01
    • 1970-01-01
    • 2012-11-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多