zoukankan      html  css  js  c++  java
  • 配置AJAX Enabled WCF在hosting时: Showing the serviceMetadata in an ASP.NET AJAX Service

    Here's an example of configuring a web.config file to show the meta data for an ASP.NET 3.5 AJAX WCF service.

    In this case, you first add the service using Add New Item -> AJAX-Enabled WCF Service -> (Name WeatherService.svc) -> Add.

    Next, configure the web.config's <system.serviceModel> section to look like this:

    <system.serviceModel>
    <services>
    <service name="WeatherService"
    behaviorConfiguration="WeatherServiceAspNetAjaxBehavior">

    <endpoint address=""
    binding="webHttpBinding" contract="WeatherService" />
    <endpoint contract="IMetadataExchange"
    binding="mexHttpBinding" address="mex" />
    </service>
    </services>
    <behaviors>
    <endpointBehaviors>
    <behavior name="WeatherServiceAspNetAjaxBehavior">
    <enableWebScript />
    </behavior>
    </endpointBehaviors>
    <serviceBehaviors>
    <behavior name="WeatherServiceAspNetAjaxBehavior" >
    <serviceMetadata httpGetEnabled="true" />
    </behavior>
    </serviceBehaviors>
    </behaviors>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" />
    </system.serviceModel>

     使得:

    endpointBehaviors  &serviceBehaviors 共用一个名字。

     或者如下:

    <behaviors>
          <endpointBehaviors>
            <behavior name="AjaxBehavior">
              <enableWebScript />
            </behavior>
          </endpointBehaviors>
          <serviceBehaviors>
            <behavior name="AjaxServiceBehavior">
              <serviceMetadata httpGetEnabled="true" />
            </behavior>
          </serviceBehaviors>
        </behaviors>
     
        <serviceHostingEnvironment aspNetCompatibilityEnabled="true" />
        
        <services>
          <service behaviorConfiguration="AjaxServiceBehavior" name="ShoppingCartService">
            <endpoint address="" behaviorConfiguration="AjaxBehavior"
                      binding="webHttpBinding" bindingConfiguration="AjaxBinding"
                      contract="ShoppingCartService" />
            <endpoint address="" behaviorConfiguration="AjaxBehavior" binding="webHttpBinding" bindingConfiguration="AjaxSecureBinding" contract="ShoppingCartService" />
          </service>  
        </services>

  • 相关阅读:
    [HAOI2011] 向量
    [HNOI2004] 树的计数
    [TJOI2009] 猜数字
    Wannafly Camp 2020 Day 6K 最大权值排列
    [HAOI2012] 容易题
    [ZJOI2008] 生日聚会
    [CQOI2007] 余数求和
    [CQOI2009] 中位数
    [SDOI2012] Longge的问题
    我的Apache又挂了之apache错误:server's fully qualified domain name, using 127.0.0.1. Set the 'ServerName'
  • 原文地址:https://www.cnblogs.com/simonhaninmelbourne/p/1517626.html
Copyright © 2011-2022 走看看