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

  • 相关阅读:
    批处理(bat)的一些记录
    在 Docker 中已运行的 container 如何修改 run 时的 env
    Linux 的一些命令记录
    Javascript aop(面向切面编程)之around(环绕)
    dojo Provider(script、xhr、iframe)源码解析
    dojo/request模块整体架构解析
    require、module、exports dojo中的三个特殊模块标识
    CSS垂直居中总结
    Javascript图片裁切
    CSS Font知识整理总结
  • 原文地址:https://www.cnblogs.com/simonhaninmelbourne/p/1517626.html
Copyright © 2020-2023  润新知