示例#1
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, Microsoft.AspNetCore.Hosting.IHostingEnvironment env)
        {
            if (env.IsDevelopment())
            {
                env.UseRootNodeModules();
                app.UseBrowserLink();
                app.UseDeveloperExceptionPage();
            }
            else
            {
                app.UseExceptionHandler("/Home/Error");
            }

            app.UseForwardedHeaders(new ForwardedHeadersOptions
            {
                ForwardedHeaders = Microsoft.AspNetCore.HttpOverrides.ForwardedHeaders.XForwardedFor | Microsoft.AspNetCore.HttpOverrides.ForwardedHeaders.XForwardedProto
            });

            app.UseAuthentication();
            app.UseStaticFiles();

            app.UseSignalR(routes =>
            {
                routes.MapHub <Common.Hubs.SubscriberSyncHub>("/subscribersynchub");
                routes.MapHub <Common.Hubs.MessagingHub>("/messaginghub");
            });

            app.UseMvc(routes =>
            {
                routes.MapRoute(
                    name: "default",
                    template: "{controller=Home}/{action=Index}");
                routes.MapRoute(
                    name: "shortLinksWithSubscriber",
                    template: Common.Helpers.UrlShortenerHelper.RoutePrefix + "={key}&{id}",
                    defaults: new { controller = "Home", action = "ShortLinkWithSubscriber" });
                routes.MapRoute(
                    name: "shortLinksWithoutSubscriber",
                    template: Common.Helpers.UrlShortenerHelper.RoutePrefix + "={key}",
                    defaults: new { controller = "Home", action = "ShortLinkWithoutSubscriber" });
            });
        }