已拦截跨源请求:同源策略禁止读取位于 http://47.55.32.128:8081/abj_api/Login/GetRoleFunctions?roleId=800 的远程资源。(原因:CORS 请求未能成功)。
后台接口提供方需要做如下修改:
Global.asax配置,添加如下方法
protected void Application_BeginRequest(object sender, EventArgs e){System.Web.HttpApplication app = sender as System.Web.HttpApplication;HttpResponse response = app.Response;if (app.Request.HttpMethod == "OPTIONS"){response.AddHeader("Access-Control-Allow-Methods", "*");response.AddHeader("Access-Control-Allow-Headers", "*");response.AddHeader("Access-Control-Allow-Origin", "*");response.AddHeader("Cache-Control", "no-cache"); response.StatusCode = 200;response.End();}else{response.AddHeader("Access-Control-Allow-Origin", "*");response.AddHeader("Access-Control-Allow-Headers", "*");response.AddHeader("Access-Control-Allow-Methods", "*");response.AddHeader("Cache-Control", "no-cache");}}