2016年4月18日 星期一

self-hosting console 的 signalr 使用靜態網頁

Startup 類別的 Configuration(IAppBuilder app) 裡添加程式碼:

           app.Map("/signalr", map =>
            {
                // To enable CORS requests, Install-Package Microsoft.Owin.Cors

                // Setup the cors middleware to run before SignalR.
                // By default this will allow all origins. You can
                // configure the set of origins and/or http verbs by
                // providing a cors options with a different policy.
                map.UseCors(CorsOptions.AllowAll);

                var hubConfiguration = new HubConfiguration
                {
                    // You can enable JSONP by uncommenting line below.
                    // JSONP requests are insecure but some older browsers (and some
                    // versions of IE) require JSONP to work cross domain
                    // EnableJSONP = true
                };

                // Run the SignalR pipeline. We're not using MapSignalR
                // since this branch is already runs under the "/signalr"
                // path.
                map.RunSignalR(hubConfiguration);
            });
            // 這裡是新添加的部分
            var physicalFileSystem = new PhysicalFileSystem(@"./www");
            var options = new FileServerOptions
            {
                EnableDefaultFiles = true,
                FileSystem = physicalFileSystem
            };
            options.StaticFileOptions.FileSystem = physicalFileSystem;
            options.StaticFileOptions.ServeUnknownFileTypes = true;
            options.DefaultFilesOptions.DefaultFileNames = new[] { "index.html" };
            app.UseFileServer(options);
            //
            app.UseWelcomePage();


[專案名稱]\bin\Debug 裡新增資料夾 www





1 則留言:

quintouher 提到...

Slots Machine - Dr.MCD
This slot machine has 5 reels, 3 rows, and is designed for 목포 출장샵 real money video 순천 출장안마 slots. The slot machine 거제 출장안마 is 동두천 출장안마 loaded with features to  Rating: 3.6 · ‎51 reviews 화성 출장샵