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>
  • 相关阅读:
    java 策略模式
    Android使用ListView应该注意的地方
    Zxing android 解析流程
    java 工厂模式
    Java 单例模式
    TextView的属性详解
    java 装饰者模式
    CSS outline:none
    php数组
    利用Google API快速生成QR二维码
  • 原文地址:https://www.cnblogs.com/fengwenit/p/5517501.html
Copyright © 2011-2022 走看看