在包含网站中使用 FormsAuthentication 时,WCF 4 引发异常

发布于 2024-09-13 21:32:32 字数 420 浏览 1 评论 0原文

我的 ASP.Net MVC 2 项目的文件夹中有一个 WCF 4 REST WebService。还可以使用“crossDomainScriptAccessEnabled”绑定选项在服务上启用 JSONP。 该网站和服务都很棒。但是,我刚刚注意到,如果您登录到网站(意味着您有 cookie),然后通过在浏览器中点击 URL 来“测试”API 方法,我会收到此错误:

跨域 不支持 JavaScript 回调 在经过身份验证的服务中。

我在网站内使用表单身份验证。在我的本地计算机上运行和部署时都会发生这种情况。

在 Asp.net 论坛上阅读让我想到需要设置一个配置设置以确保身份验证设置为匿名。有没有人找到办法解决这个问题?有没有办法告诉 WCF 忽略 FormAuthentication cookie?

I have a WCF 4 REST WebService within a folder in my ASP.Net MVC 2 project. JSONP is also enabled on the service using the 'crossDomainScriptAccessEnabled' binding option.
The site and service work great. But, I just noticed that if you are signed in to the website (meaning you have a cookie) and then you 'test' an API method by hitting the URL in the browser I get this error:

Cross domain
javascript callback is not supported
in authenticated services.

I'm using Forms Authentication within the site. This happens both when running on my local machine and deployed.

Reading on the Asp.net forums made me think there is an config setting that I need to set to make sure authentication is set to anonymous. Has anyone found a way to get around this? Is there a way to tell WCF to ignore the FormAuthentication cookie?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

木森分化 2024-09-20 21:32:32

尝试在 内的 web.config 中设置 看看这是否在本地有效。

Try setting <authentication mode="None"/> in web.config inside <system.web> to see if this works locally.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文