c# - Azure 服务总线托管 REST 服务

标签 c# wcf azure azure-web-roles azureservicebus

我正在尝试托管可从 Azure 服务总线中继的 REST 服务 我看到this blog看起来它可以回答我的问题,但不幸的是,我得到了相同的结果。

这是我在尝试访问浏览器中的服务时收到的异常。

The service cannot be activated because it does not support ASP.NET compatibility. ASP.NET compatibility is enabled for this application. Turn off ASP.NET compatibility mode in the web.config or add the AspNetCompatibilityRequirements attribute to the service type with RequirementsMode setting as 'Allowed' or 'Required'.

如果我从连接到 Azure 服务总线的 ServiceHostFactory 中排除 Azure 端点注册(通过 basicHttpRelayBinding ),我不会收到此错误,并且可以点击本地服务。它与托管 RESTful 服务 (webHttpBinding) 和 Azure 服务总线中继绑定(bind) (basicHttpRelayBinding) 有关。

在 global.asax 中,我添加了服务托管

protected void Application_Start(object sender, EventArgs e)
{
    // Add REST service hosting.
    RouteTable.Routes.Add(new ServiceRoute("myservice/rest",
         new CustomWebServiceHostFactory(typeof(IMyService)),
         typeof(MyServiceProvider)));
}

我已将我的服务提供商装饰如下:

[ServiceBehavior(IncludeExceptionDetailInFaults = true)]
[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
public class MyServiceProvider : IMyService
{
    ...
}

在 IIS 中运行的服务接口(interface)的 web.config 具有以下值:

<configSections>
    <sectionGroup name="system.serviceModel" type="System.ServiceModel.Configuration.ServiceModelSectionGroup, System.ServiceModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
      <section name="standardEndpoints" type="System.ServiceModel.Configuration.StandardEndpointsSection, System.ServiceModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
    </sectionGroup>           
</configSections>

<system.serviceModel>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" />
    <standardEndpoints>
       <webHttpEndpoint>
          <standardEndpoint helpEnabled="true" automaticFormatSelectionEnabled="true">
             <security mode="None"/>
          </standardEndpoint>
       </webHttpEndpoint>
    </standardEndpoints>
...
</system.serviceModel>

有什么想法吗?

最佳答案

我可以建议您尝试我的这个博客,其中显示了完全相同的问题以及根本原因和解决方案,尝试应用该建议并让我们知道:

http://blogs.msdn.com/b/avkashchauhan/archive/2011/11/17/wcf-rest-http-application-connecting-azure-service-bus-using-webhttprelaybinding-causes-aspnetcompatibilityenabled-error.aspx

关于c# - Azure 服务总线托管 REST 服务,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10839191/

相关文章:

azure - 是否可以使用 Azure 自动化 Runbook 删除另一个 Runbook 输出(Azure 文件共享快照)?

c# - 使用 StructureMap 注入(inject)自定义成员提供程序

wcf - 可怕的 "could not find a base address that matches scheme http"如何让它与 SSL 一起工作?

c# - WCF 与托管应用程序通信?

azure - 架构漂移未按预期 Azure DF 工作(2 种不同架构格式的多个文件)

visual-studio - 使用 Web 应用程序创建数据库时 Azure NoRegisteredProviderFound

c# - 如何从返回 Task<T> 的异步函数返回错误

c# - 如何研究 .NET 中的非托管内存泄漏?

c# - 将多维数组转换为字符串并返回

wcf - IIS 托管应用程序中的控制台输出在哪里?