在我的之前随笔 解决api.WebService跨域问题 中有人问到可以用特性来解决跨域问题吗,答案是肯定的,可以的:操作如下: 首先建一个类CrossSiteAttribute:从抽象 ActionFilterAttribute 类继承的特性类来创建操作筛选器或响应筛选器.然后重写方法 OnActionExecuted实现跨域 using System.Web.Http.Filters; namespace Api { public class CrossSiteAttribute : Act
一.传统 ajax跨域访问是一个老问题了,解决方法很多,比较常用的是JSONP方法,JSONP方法是一种非官方方法,而且这种方法只支持GET方式,不如POST方式安全. 即使使用jQuery的jsonp方法,type设为POST,也会自动变为GET. 官方问题说明: "script": Evaluates the response as JavaScript and returns it as plain text. Disables caching by appending a qu