• 配置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>

  • 相关阅读:
    这是另外一篇
    使用客户端写博客
    vim编码相关配置
    给eclipse装一些插件
    手机型号收集
    解决黑苹果与windows时区不一致
    记录一些在VPS上折腾的东西
    一个获取文件绝对路径的sh
    python批量GBK转UTF-8
    用NDK编译lua库
  • 原文地址:https://www.cnblogs.com/simonhaninmelbourne/p/1517626.html
Copyright © 2020-2023  润新知