zoukankan      html  css  js  c++  java
  • WCF 改成 restful api

    1.  右健 svc , view markup, 添加

    Factory="System.ServiceModel.Activation.WebServiceHostFactory"

     

    2. 在接口上添加:

     [WebInvoke(UriTemplate = "{name}/{type}/{count}", Method = "GET", ResponseFormat = WebMessageFormat.Json)]

     

    3. No 'Access-Control-Allow-Origin' header is present on the requested resource

     

    3.1  add the CORS NuGet package. In Visual Studio, from the Tools menu, select Library Package Manager, then select Package Manager Console. In the Package Manager Console window, type the following command:

    Install-Package Microsoft.AspNet.WebApi.Cors 

     

    3.2 类上加,不是接口上加

    [EnableCors(origins: "http://www.48.red:81", headers: "*", methods: "*")]

     

    3.3 web.config:

    <system.webServer>
      ...
    
        <httpProtocol>
            <customHeaders>
                <!-- Enable Cross Domain AJAX calls -->
                <remove name="Access-Control-Allow-Origin" />
                <add name="Access-Control-Allow-Origin" value="*" />
            </customHeaders>
        </httpProtocol>
    </system.webServer>
  • 相关阅读:
    stl-序列式容器
    BFS
    Hash
    二分法
    草稿1
    红黑树的左旋、右旋和颜色变换
    动态规划
    自动驾驶-安全
    二叉树

  • 原文地址:https://www.cnblogs.com/fengwenit/p/5517501.html
Copyright © 2011-2022 走看看