Exemple #1
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(
            IApplicationBuilder app,
            IHostingEnvironment env,
            IApplicationLifetime applicationLifetime
            )
        {
            // Start MQTT
            var broker = new MqttBroker(Configuration, app.ApplicationServices.GetService <IServiceProvider>());

            // On application exit terminate MQTT to make sure the connection is ended properly
            applicationLifetime.ApplicationStopping.Register(() => broker.Terminate());

            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
                app.UseDatabaseErrorPage();
            }
            else
            {
                app.UseExceptionHandler("/Home/Error");
                app.UseHsts();
                app.UseHttpsRedirection(); //enkel redirecten in production aangezien https niet werkt in development
            }

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

            app.UseMvc(routes =>
            {
                routes.MapSubdomainRoute(
                    Constants.hostnames,
                    "TenantInSubdomain",
                    "{tenant}",
                    "{controller}/{action}",
                    new { controller = "Platform", action = "Index" }
                    );

                routes.MapRoute(
                    name: "default",
                    template: "{controller=Home}/{action=Index}/{id?}");
            });

            app.UseSignalR(routes =>
            {
                routes.MapHub <VoteHub>("/votehub");
                routes.MapHub <ActivityHub>("/activityhub");
            });
        }