• 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>
  • 相关阅读:
    HDFS Java API
    HBase Java API
    Hive JDBC
    map.merge() 方法
    循环的4种形式
    Storm 单词计数
    swagger 2.9.2
    ZooKeeper Java API
    服务器添加静态路由
    Win10局域网共享文件夹“用户名或密码不正确”
  • 原文地址:https://www.cnblogs.com/fengwenit/p/5517501.html
Copyright © 2020-2023  润新知