惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

S
Schneier on Security
Hugging Face - Blog
Hugging Face - Blog
V
Visual Studio Blog
博客园 - Franky
酷 壳 – CoolShell
酷 壳 – CoolShell
Last Week in AI
Last Week in AI
博客园 - 叶小钗
博客园_首页
阮一峰的网络日志
阮一峰的网络日志
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
Application and Cybersecurity Blog
Application and Cybersecurity Blog
TaoSecurity Blog
TaoSecurity Blog
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
J
Java Code Geeks
爱范儿
爱范儿
宝玉的分享
宝玉的分享
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
量子位
N
News and Events Feed by Topic
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
Recent Commits to openclaw:main
Recent Commits to openclaw:main
SecWiki News
SecWiki News
MyScale Blog
MyScale Blog
AI
AI
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
博客园 - 【当耐特】
Security Archives - TechRepublic
Security Archives - TechRepublic
F
Fortinet All Blogs
V2EX - 技术
V2EX - 技术
T
Troy Hunt's Blog
有赞技术团队
有赞技术团队
W
WeLiveSecurity
Project Zero
Project Zero
T
Tor Project blog
Help Net Security
Help Net Security
L
LINUX DO - 最新话题
IT之家
IT之家
The Hacker News
The Hacker News
腾讯CDC
Schneier on Security
Schneier on Security
N
News and Events Feed by Topic
C
Cisco Blogs
博客园 - 聂微东
Webroot Blog
Webroot Blog
Forbes - Security
Forbes - Security
M
MIT News - Artificial intelligence
C
Cyber Attacks, Cyber Crime and Cyber Security
雷峰网
雷峰网
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
A
About on SuperTechFans

博客园 - Yu

Illegal characters in path 依赖注入的 Singleton、Scoped、Transient vs2015 编译报错:The project references NuGet package(s) that are missing on this computer... discuz 迁移 uc_server 报错 The timeout period elapsed prior to completion of the operation or the server is not responding. 微信小程序笔记 xmlns 与 targetNamespace 的解释 Ubuntu64 apache2+lvs+Keepalived NPOI CellStyle 设置 mysql --initialize specified but the data directory has files in it select2 多选设置默认值 VS 2015 IDE 不支持 MS SQL 2000 生成 dbml Ajax 如何执行 Response.Redirect ng 发生 Error: ELOOP: too many symbolic links encountered... HtmlAgilityPack 使用 微信 oauth2 两次回调 EF 热加载 Winform/Asp.net vs2015 使用 Eazfuscator.NET 3.3 The requested page cannot be accessed because the related configuration data for the page is invalid.
jquery call cross-domain webapi owin self-host
Yu · 2017-09-01 · via 博客园 - Yu
<!DOCTYPE HTML>
<html LANG="cn">
<head>
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>cross domain IE5-11</title>
    <script type="text/javascript" src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
    <script>
         $(function(){
			$.support.cors = true; // support to IE5-11
			$.ajax({
				type: "GET",
				url: "http://xxx-services:8081/api/values/99",
				dataType: "json"
			}).done(function (data) {
				console.log(data);
			});
        });
    </script>
</head>
<body>
</body>
</html>

public class ValuesController : ApiController
{
        public async Task<string> Get(int id)
        {
            var info = string.Format("API CurrentThread:{0}", Thread.CurrentThread.ManagedThreadId);
            var infoTask = await GetCurrentThread();
            var infoTaskFinished = string.Format("After GetCurrentThread:{0}", Thread.CurrentThread.ManagedThreadId);
            return string.Format("{0},{1},{2},{3}", info, infoTask, infoTaskFinished, id);
        }

        private async Task<string> GetCurrentThread()
        {
            await Task.Delay(1500);
            return string.Format("Action CurrentThread:{0}", Thread.CurrentThread.ManagedThreadId);
        }
}
public class Startup
{
    public void Configuration(IAppBuilder MyApp)
    {
            HttpConfiguration config = new HttpConfiguration();
            config.Routes.MapHttpRoute(name: "DefaultApi", routeTemplate: "api/{controller}/{id}",
                defaults: new { id = RouteParameter.Optional }
                );
       MyApp.UseCors(Microsoft.Owin.Cors.CorsOptions.AllowAll); MyApp.UseWebApi(config); } }
//window service hosting

public
class MyControllersService : ServiceHelper.BaseService { bool isstart = false; public MyControllersService() : base("MyControllersService", true) { } protected override void MyWork() { try { this.OutputLog("MyWork Start", this.ServiceName); string address = "http://xxx-services:8081/"; if(!isstart) { WebApp.Start<Startup>(url: address); isstart = true; this.OutputLog("Starting OWIN Host", this.ServiceName); } } catch (Exception err) { this.OutputLog(CommonHelper.CommonUnit.ExceptionMsg(err), this.ServiceName); throw; } finally { this.OutputLog("MyWork Stop", this.ServiceName); }     } }