Esempio n. 1
0
        public void Configuration(IAppBuilder app)
        {
            //Startup.ConfigureAuth();
            app.UseErrorPage();             // See Microsoft.Owin.Diagnostics
            app.UseWelcomePage("/Welcome"); // See Microsoft.Owin.Diagnostics
            //app.Run(async context =>
            //{
            //    await context.Response.WriteAsync("Hello world using OWIN TestServer");
            //});

            //Get your HttpConfiguration. In OWIN, you'll create one
            //rather than using GlobalConfiguration.
            var config = new HttpConfiguration();

            WebApiConfig.Register(config);



            //// OWIN WEB API SETUP:

            //// Register the Autofac middleware FIRST, then the Autofac Web API middleware,
            //// and finally the standard Web API middleware.
            app.UseWebApi(config);

            HttpContext.Current = new HttpContext(new HttpRequest("", "http://tempuri.org", ""),
                                                  new HttpResponse(new StringWriter())
                                                  );
        }
Esempio n. 2
0
        public void Configuration(IAppBuilder app)
        {
            // from Owin.Diagnostics
            app.UseWelcomePage();

            // low level app.Run
            //app.Run(ctx =>
            //{
            //    foreach (var kvp in ctx.Environment)
            //    {
            //        Console.WriteLine("{0}:{1}", kvp.Key, kvp.Value);
            //    }
            //    return ctx.Response.WriteAsync("Hello!");
            //});


            // Synch Handler
            // app.UseHandler((request, response) =>
            //    {
            //       response.Write("Hello!");
            //    });

            // Asynch handler
            //app.UseHandlerAsync((request, response) =>
            //{
            //    response.ContentType = "text/plain";
            //    return response.WriteAsync("Hello!");
            //});
        }
Esempio n. 3
0
        public void Configuration(IAppBuilder app)
        {
            // from Owin.Diagnostics
            app.UseWelcomePage();

            // low level app.Run
            //app.Run(ctx =>
            //{
            //    foreach (var kvp in ctx.Environment)
            //    {
            //        Console.WriteLine("{0}:{1}", kvp.Key, kvp.Value);
            //    }
            //    return ctx.Response.WriteAsync("Hello!");
            //});

            // Synch Handler
            // app.UseHandler((request, response) =>
            //    {
            //       response.Write("Hello!");
            //    });

            // Asynch handler
            //app.UseHandlerAsync((request, response) =>
            //{
            //    response.ContentType = "text/plain";
            //    return response.WriteAsync("Hello!");
            //});
        }
Esempio n. 4
0
        public void Configuration(IAppBuilder app)
        {
            #if DEBUG
            app.UseErrorPage();
            #endif

            app.UseWelcomePage(new Microsoft.Owin.Diagnostics.WelcomePageOptions()
            {
                Path = new PathString("/welcome")
            });

            app.Run(context =>
            {
                context.Response.ContentType = "text/html";

                string output = string.Format(
                    "<p>I'm running on {0} </p><p>From assembly {1}</p>",
                    Environment.OSVersion,
                    System.Reflection.Assembly.GetEntryAssembly().FullName
                    );

                return context.Response.WriteAsync(output);

            });
        }
Esempio n. 5
0
        public void Configuration(IAppBuilder app)
        {
            // Show an error page
            app.UseErrorPage();

            // Logging component
            app.Use<LoggingComponent>();

            // Configure web api routing
            var config = new HttpConfiguration();
            config.MapHttpAttributeRoutes();
            config.Routes.MapHttpRoute(
                name: "DefaultApi",
                routeTemplate: "api/{controller}/{id}",
                defaults: new { id = RouteParameter.Optional }
            );

            // Use web api middleware
            app.UseWebApi(config);

            // Throw an exception
            app.Use(async (context, next) =>
            {
                if (context.Request.Path.ToString() == "/fail")
                    throw new Exception("Doh!");
                await next();
            });

            // Welcome page
            app.UseWelcomePage("/");
        }
Esempio n. 6
0
        public void Configuration(IAppBuilder app)
        {
            // For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=316888
#if DEBUG
            app.UseErrorPage();
#endif
            app.UseWelcomePage("/welcome");

            HttpConfiguration config = new HttpConfiguration();
            config.MapHttpAttributeRoutes();
            config.Formatters.Clear();
            JsonMediaTypeFormatter json = new JsonMediaTypeFormatter();
            json.SerializerSettings = new Newtonsoft.Json.JsonSerializerSettings()
            {
                ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore
            };
            config.Formatters.Add(json);
            //config.Formatters.Add(new JsonMediaTypeFormatter());
            app.UseWebApi(config);


            app.UseSwaggerUi3(typeof(Startup).Assembly, settings =>
            {
            });
        }
Esempio n. 7
0
        public void Configuration(IAppBuilder app)
        {
            #if DEBUG
            app.UseErrorPage();
            #endif

            app.UseWelcomePage("/");

            app.Run(context =>
            {
                if (context.Request.Path == new PathString("/test"))
                {
                    return(context.Response.WriteAsync("Hello, world"));
                }

                if (context.Request.Path == new PathString("/get"))
                {
                    return(context.Response.WriteAsync("get"));
                }

                if (context.Request.Path == new PathString("/set"))
                {
                    return(context.Response.WriteAsync("set"));
                }

                return(context.Response.WriteAsync("what"));
            });
        }
Esempio n. 8
0
        void Initialize(IAppBuilder app)
        {
#if DEBUG
            app.UseErrorPage();
#endif
            app.UseWelcomePage("/");
        }
Esempio n. 9
0
        public void Configuration(IAppBuilder app)
        {
            // Configure StructureMap

            var container = new Container(cfg =>
            {
                cfg.For <ISession>().Use <DbSession>();
            });

            app.UseStructureMap(container);

            // Other middleware
            app.Use(typeof(LoggingMiddleware));
            app.UseWelcomePage("/");


            // Configure Web API

            var httpConfiguration = new HttpConfiguration();

            httpConfiguration.Formatters.Remove(httpConfiguration.Formatters.XmlFormatter);

            httpConfiguration.Routes.MapHttpRoute("Default", "{controller}");
            httpConfiguration.Filters.Add(new UnitOfWorkFilter());

            app.UseWebApiWithStructureMap(httpConfiguration, container);
        }
Esempio n. 10
0
        public void Configuration(IAppBuilder app)
        {
            #if DEBUG
            app.UseErrorPage(new ErrorPageOptions
            {
                //Shows the OWIN environment dictionary keys and values.
                //This detail is enabled by default if you are running your app from VS unless disabled in code.
                ShowEnvironment = true,
                //Hides cookie details
                ShowCookies = true,
                //Shows the lines of code throwing this exception.
                //This detail is enabled by default if you are running your app from VS unless disabled in code.
                ShowSourceCode = true
            });

            //for test ErrorPage
            //app.Run(async context =>
            //{
            //    throw new Exception("UseErrorPage() demo");
            //    await context.Response.WriteAsync("Error page demo");
            //});

            app.UseWelcomePage("/"); // for test purpose only
            #endif

            ConfigureOAuth(app);

            var config = new HttpConfiguration();
            WebApiConfig.Register(config);

            app.UseCors(Microsoft.Owin.Cors.CorsOptions.AllowAll);
            app.UseWebApi(config);
        }
Esempio n. 11
0
        public void Configuration(IAppBuilder app)
        {
            app.UseErrorPage();

            // Remap '/' to '.\defaults\'.
            // Turns on static files and default files.
            app.UseFileServer(new FileServerOptions()
            {
                RequestPath = PathString.Empty,
                FileSystem  = new PhysicalFileSystem(@".\"),
            });

            HttpConfiguration config = new HttpConfiguration();

            config.MapHttpAttributeRoutes();

            //config.Routes.MapHttpRoute("Default", "{controller}/{checkinID}", new { controller = "Checkin", checkinID = RouteParameter.Optional });
            //config.Routes.MapHttpRoute("Default3", "{controller}/route/{arg}", new { controller = "Checkin", checkinID = RouteParameter.Optional });
            config.Routes.MapHttpRoute("Default", "{controller}/{commitID}", new { controller = "Commit", commitID = RouteParameter.Optional });
            config.Routes.MapHttpRoute("Default2", "{controller}", new { controller = "Repository" });
            config.Routes.MapHttpRoute("Default3", "{controller}/{user}", new { controller = "User", user = RouteParameter.Optional });

            //config.Formatters.XmlFormatter.UseXmlSerializer = true;
            //config.Formatters.Remove(config.Formatters.JsonFormatter);
            config.Formatters.Remove(config.Formatters.XmlFormatter);
            config.Formatters.JsonFormatter.UseDataContractJsonSerializer = true;

            app.UseWebApi(config);
            app.UseWelcomePage();
        }
Esempio n. 12
0
        public static IAppBuilder MapConreignApi(
            this IAppBuilder builder,
            IOrleansClientInitializer initializer,
            ConreignApiConfiguration configuration)
        {
            if (builder == null)
            {
                throw new ArgumentNullException(nameof(builder));
            }
            if (initializer == null)
            {
                throw new ArgumentNullException(nameof(initializer));
            }
            if (configuration == null)
            {
                throw new ArgumentNullException(nameof(configuration));
            }
            var container = new Container();

            container.Options.DefaultScopedLifestyle = new AsyncScopedLifestyle();
            container.RegisterConreignApi(initializer, configuration);
            var hubConfiguration = ConfigureSignalR(container);

            builder.UseWelcomePage("/");
            builder.MapSignalR <SimpleInjectorHubDispatcher>("/$/api", hubConfiguration);
            return(builder);
        }
Esempio n. 13
0
        public void Configuration(IAppBuilder app)
        {
            /* // Note: Enable only for debugging. This slows down the perf tests.
            app.Use((context, next) =>
            {
                var req = context.Request;
                context.TraceOutput.WriteLine("{0} {1}{2} {3}", req.Method, req.PathBase, req.Path, req.QueryString);
                return next();
            });*/

            app.UseErrorPage(new ErrorPageOptions { SourceCodeLineCount = 20 });
            // app.Use(typeof(AutoTuneMiddleware), app.Properties["Microsoft.Owin.Host.HttpListener.OwinHttpListener"]);
            app.UseSendFileFallback();
            app.Use<CanonicalRequestPatterns>();

            app.UseStaticFiles(new StaticFileOptions()
            {
                RequestPath = new PathString("/static"),
                FileSystem = new PhysicalFileSystem("public")
            });
            app.UseDirectoryBrowser(new DirectoryBrowserOptions()
            {
                RequestPath = new PathString("/static"),
                FileSystem = new PhysicalFileSystem("public")
            });
            app.UseStageMarker(PipelineStage.MapHandler);

            FileServerOptions options = new FileServerOptions();
            options.EnableDirectoryBrowsing = true;
            options.StaticFileOptions.ServeUnknownFileTypes = true;

            app.UseWelcomePage("/Welcome");
        }
Esempio n. 14
0
        public void Configuration(IAppBuilder app)
        {
#if DEBUG
            app.UseErrorPage();
#endif
            app.UseWelcomePage("/");
        }
Esempio n. 15
0
 public void Configuration(IAppBuilder app)
 {
     ConfigureStaticFileServer(app);
     ConfigureWebApi(app);
     // Anything not handled will land at the welcome page.
     app.UseWelcomePage();
 }
Esempio n. 16
0
        public void Configuration(IAppBuilder app)
        {
            // Consume bearer tokens
            var options = new OAuthBearerAuthenticationOptions
            {
                // Authn Filter asks for authentication
                AuthenticationMode = AuthenticationMode.Passive
            };

            app.UseOAuthBearerAuthentication(options);

            // Configure web api routing
            var config = new HttpConfiguration();

            config.MapHttpAttributeRoutes();
            config.Routes.MapHttpRoute(
                "DefaultApi",
                "api/{controller}/{id}",
                new { id = RouteParameter.Optional });
            app.UseWebApi(config);

            // Add error, welcome pages
            app.UseErrorPage();
            app.UseWelcomePage();
        }
Esempio n. 17
0
        public static void Configuration(IAppBuilder app)
        {
            app.UseWelcomePage("/");
            app.UseErrorPage();

            HttpConfiguration config = new HttpConfiguration();

            app.UseCors(Microsoft.Owin.Cors.CorsOptions.AllowAll);

            var OAuthOptions = new OAuthAuthorizationServerOptions
            {
                AllowInsecureHttp         = true,
                TokenEndpointPath         = new PathString("/oauth/Token"),
                AccessTokenExpireTimeSpan = TimeSpan.FromHours(8),
                Provider             = new Providers.MyAuthorizationServerProvider(),
                RefreshTokenProvider = new Providers.MyRefreshTokenProvider(DateTime.UtcNow.AddHours(8))
            };

            app.UseOAuthAuthorizationServer(OAuthOptions);
            app.UseOAuthBearerAuthentication(new OAuthBearerAuthenticationOptions());

            config.SuppressDefaultHostAuthentication();
            config.Filters.Add(new HostAuthenticationFilter(OAuthDefaults.AuthenticationType));

            // There's no public API here. It's just an authentication server.

            //config.MapHttpAttributeRoutes();
            //app.UseWebApi(config);
        }
Esempio n. 18
0
        public void Configuration(IAppBuilder app)
        {
            // For more information on how to configure your application, visit http://go.microsoft.com/fwlink/?LinkID=316888


            app.UseWelcomePage("/");

            app.UseErrorPage();
            app.UseAesDataProtectionProvider();

            var oauthserOpt = new OAuthAuthorizationServerOptions();
            var option      = new OAuthBearerAuthenticationOptions()
            {
                AccessTokenFormat   = oauthserOpt.AccessTokenFormat,
                AccessTokenProvider = new AccessAuthenticationTokenProvider(new DongboAuthorizationServerOptions()
                {
                    //AccessTokenLifetime=
                    ClientManager = new ClientManager(new ClientStore()),
                    //IssuerUri = new Uri("/issuer"),
                    TokenManager = new TokenManager(new TokenStore()),
                    //UserManager = new OAuthUserManager<DongboUser>(new DongboUserManager(new UserStore<DongboUser>()))
                }),
                Provider = new OAuthBearerAuthenticationProvider()
                {
                    OnRequestToken = RequestToken
                },
                AuthenticationType = "OAuth"
            };

            app.UseOAuthBearerAuthentication(option);

            app.UseCors(Microsoft.Owin.Cors.CorsOptions.AllowAll);

            var config = new HttpConfiguration();

            // 启用标记路由
            config.MapHttpAttributeRoutes();

            // 默认的 Web API 路由
            config.Routes.MapHttpRoute(
                name: "DefaultApi",
                routeTemplate: "api/{controller}/{id}",
                defaults: new { id = RouteParameter.Optional }
                );
            var cors = new System.Web.Http.Cors.EnableCorsAttribute("*", "*", "*");

            config.EnableCors(cors);
            // There can be multiple exception loggers. (By default, no exception loggers are registered.)
            //config.Services.Add(typeof(IExceptionLogger), new DongboExceptionLogger());

            // There must be exactly one exception handler. (There is a default one that may be replaced.)
            // To make this sample easier to run in a browser, replace the default exception handler with one that sends
            // back text/plain content for all errors.
            //config.Services.Replace(typeof(IExceptionHandler), new GenericTextExceptionHandler());

            //regist help page route= '/help'
            //HelpPageConfig.Register(config);
            // 将路由配置附加到 appBuilder
            app.UseWebApi(config);
        }
Esempio n. 19
0
        public void Configuration(IAppBuilder app)
        {
            app.UseErrorPage();
            app.UseWelcomePage("/");

            GlobalConfiguration.Configuration
            .UseSqlServerStorage("DefaultConnection",
                                 new SqlServerStorageOptions
            {
                QueuePollInterval = TimeSpan.FromSeconds(value: 1)
            });

            app.UseHangfireDashboard();
            app.UseHangfireServer();

            string command;

            while ((command = Console.ReadLine()) != string.Empty)
            {
                if ("job".Equals(command, StringComparison.OrdinalIgnoreCase))
                {
                    BackgroundJob.Enqueue(() => Console.WriteLine($"{Guid.NewGuid()} - BackgroundJob job completed successfully ({DateTime.Now})!"));
                }
            }

            //RecurringJob.AddOrUpdate(
            //    () => Console.WriteLine($"{DateTime.Now} Recurring job completed successfully!"),
            //    Cron.Minutely);
        }
Esempio n. 20
0
        public void Configuration(IAppBuilder app)
        {
            var scope  = new InMemoryScopeStore(Scopes.Get());
            var client = new InMemoryClientStore(Clients.Get());
            var users  = new InMemoryUserService(Users.Get());

            var factory = new IdentityServerServiceFactory
            {
                UserService = new Registration <IUserService>(users),
                ScopeStore  = new Registration <IScopeStore>(scope),
                ClientStore = new Registration <IClientStore>(client)
            };

            var options = new IdentityServerOptions
            {
                RequireSsl            = false,
                Factory               = factory,
                SiteName              = "My Test Provider",
                AuthenticationOptions = new AuthenticationOptions
                {
                    IdentityProviders = ConfigureIpds
                },
                SigningCertificate = X509.LocalMachine.My.SubjectDistinguishedName.Find("CN=testcert", false).First()
            };

            app.UseIdentityServer(options);

            app.UseWelcomePage();
        }
Esempio n. 21
0
        public void Configuration(IAppBuilder app)
        {
            // This example shows how to use the Ninject IoC container to construct the
            // Owin pipeline buider. You can use any other IoC container supported by
            // the Ioc.Modules package with just one line of code change. You can also
            // choose not to use IoC, or configure any other IoC container you like.
            var packageLocator = new PackageLocator().ProbeAllLoadedAssemblies();
            var ninject        = new StandardKernel(new Module(packageLocator));
            var builder        = ninject.Get <IBuilder>();

            // This next part defines the concrete implementation of the various
            // OWIN middleware components you want to use in your application. The
            // order that these will be chained into the OWIN pipeline will be
            // determined from the dependencies defined within the components.

            // This is a simplified example, in a real application you should provide a
            // configuration mechanism. This example will run with all default
            // configuration values.

            builder.Register(ninject.Get <NotFoundError>());
            builder.Register(ninject.Get <PrintRequest>());
            builder.Register(ninject.Get <ReportExceptions>());
            builder.Register(ninject.Get <FormsIdentification>());
            builder.Register(ninject.Get <TemplatePageRendering>());
            builder.Register(ninject.Get <AllowEverythingAuthorization>());
            builder.Register(ninject.Get <InProcessSession>());

            // The next few lines build the Owin pipeline. Note that the
            // Owin Framework builder adds to the pipeline but other middleware
            // can also be added to the pipeline before or after it.

            app.UseErrorPage();
            app.UseBuilder(builder);
            app.UseWelcomePage("/");
        }
        /// <summary>
        /// Configurations the application.
        /// </summary>
        /// <param name="app">The application.</param>
        public void Configuration(IAppBuilder app)
        {
            var logger = LogManager.GetCurrentClassLogger();

            logger.Debug("Started  Config.Configuration");

            IocConfig.UseIoc();

            app.UseIdentityClientConfig();
            app.UseResourceAuthorization();

            app.UseHttpConfig();

            // Generic Home Page
            app.UseWelcomePage("/");

            // Non-Generic Home Page
            //app.UseFileServer(new FileServerOptions
            //{
            //    FileSystem = new PhysicalFileSystem(_development ? "../../content" : "content"),
            //    RequestPath = new PathString("")
            //});

            //app.UseWelcomePage("/content");

            app.UseMetrics();

            // Uncomment after you create the database
            //app.UseOwinHangfire();
        }
        public void Configuration(IAppBuilder app)
        {
            app.UseWelcomePage(new PathString("/Welcome"));

            app.UseFileServer(new FileServerOptions
            {
                EnableDirectoryBrowsing = false,
                FileSystem = new PhysicalFileSystem(@"..\..\..\KatanaApp\StaticResources"),
                RequestPath = new PathString(@"/contents")
            });

            app.Run(ctx =>
            {
                if (string.IsNullOrEmpty(ctx.Request.Path.Value) || ctx.Request.Path.Value == "/" || ctx.Request.Path.Value == "/Welcome/")
                {
                    ctx.Response.Redirect("/app/Welcome");
                }
                // New code: Throw an exception for this URI path.
                if (ctx.Request.Path.Value == @"/fail")
                {
                    throw new HttpException(500, "Random exception");
                }
                ctx.Response.ContentType = "text/plain";
                return ctx.Response.WriteAsync("Hello World!");
            });
        }
Esempio n. 24
0
        public void Configuration(IAppBuilder app)
        {
#if DEBUG
            app.UseErrorPage();
#endif
            // Remap '/' to '.\defaults\'.
            // Turns on static files and default files.
            app.UseFileServer(new FileServerOptions()
            {
                RequestPath = PathString.Empty,
                FileSystem  = new PhysicalFileSystem(@".\defaults"),
            });

            // Only serve files requested by name.
            app.UseStaticFiles("/files");

            // Turns on static files, directory browsing, and default files.
            app.UseFileServer(new FileServerOptions()
            {
                RequestPath             = new PathString("/public"),
                EnableDirectoryBrowsing = true,
            });

            // Browse the root of your application (but do not serve the files).
            // NOTE: Avoid serving static files from the root of your application or bin folder,
            // it allows people to download your application binaries, config files, etc..
            app.UseDirectoryBrowser(new DirectoryBrowserOptions()
            {
                RequestPath = new PathString("/src"),
                FileSystem  = new PhysicalFileSystem(@""),
            });

            // Anything not handled will land at the welcome page.
            app.UseWelcomePage();
        }
Esempio n. 25
0
 public void Configuration(IAppBuilder app)
 {
     app.UseWelcomePage();
     //app.Run(ctx => {
     //    return ctx.Response.WriteAsync("Hello world!");
     //});
 }
Esempio n. 26
0
        private void Startup(IAppBuilder appBuilder)
        {
#if DEBUG
            appBuilder.Properties["host.AppMode"] = "development";  // TODO why development ???
            appBuilder.UseErrorPage(new Microsoft.Owin.Diagnostics.ErrorPageOptions {
                ShowExceptionDetails = true
            });
#else
            appBuilder.UseErrorPage();
#endif

            ConfigureWebApi(appBuilder);

            if (UseSignalR)
            {
                ConfigureSignalR(appBuilder);
            }

            if (UseFileServer)
            {
                ConfigureFileServer(appBuilder);
            }
            else
            {
                appBuilder.UseWelcomePage("/owin/");
            }
        }
Esempio n. 27
0
        public void Configuration(IAppBuilder app)
        {
#if DEBUG
            app.UseErrorPage();
#endif


            app.UseWelcomePage(new Microsoft.Owin.Diagnostics.WelcomePageOptions()
            {
                Path = new PathString("/welcome")
            });

            app.Run(context =>
            {
                context.Response.ContentType = "text/html";

                string output = string.Format(
                    "<p>I'm running on {0} </p><p>From assembly {1}</p>",
                    Environment.OSVersion,
                    System.Reflection.Assembly.GetEntryAssembly().FullName
                    );

                return(context.Response.WriteAsync(output));
            });
        }
        public void Configuration(IAppBuilder app)
        {
#if DEBUG
            app.UseErrorPage();
#endif
            // Remap '/' to '.\defaults\'.
            // Turns on static files and default files.
            app.UseFileServer(new FileServerOptions()
            {
                RequestPath = PathString.Empty,
                FileSystem = new PhysicalFileSystem(@".\defaults"),
            });

            // Only serve files requested by name.
            app.UseStaticFiles("/files");

            // Turns on static files, directory browsing, and default files.
            app.UseFileServer(new FileServerOptions()
            {
                RequestPath = new PathString("/public"),
                EnableDirectoryBrowsing = true,
            });

            // Browse the root of your application (but do not serve the files).
            // NOTE: Avoid serving static files from the root of your application or bin folder,
            // it allows people to download your application binaries, config files, etc..
            app.UseDirectoryBrowser(new DirectoryBrowserOptions()
            {
                RequestPath = new PathString("/src"),
                FileSystem = new PhysicalFileSystem(@""),
            });

            // Anything not handled will land at the welcome page.
            app.UseWelcomePage();
        }
Esempio n. 29
0
        public void Configuration(IAppBuilder app)
        {
            // Show an error page
            app.UseErrorPage();

            // Logging component
            app.Use <LoggingComponent>();

            // Configure web api routing
            var config = new HttpConfiguration();

            config.MapHttpAttributeRoutes();
            config.Routes.MapHttpRoute(
                name: "DefaultApi",
                routeTemplate: "api/{controller}/{id}",
                defaults: new { id = RouteParameter.Optional }
                );

            // Use web api middleware
            app.UseWebApi(config);

            // Throw an exception
            app.Use(async(context, next) =>
            {
                if (context.Request.Path.ToString() == "/fail")
                {
                    throw new Exception("Doh!");
                }
                await next();
            });

            // Welcome page
            app.UseWelcomePage("/");
        }
Esempio n. 30
0
        public void Configuration(IAppBuilder app)
        {
            var config  = new HttpConfiguration();
            var builder = new ContainerBuilder();

            // Set working directory
            Environment.CurrentDirectory = System.AppDomain.CurrentDomain.BaseDirectory;

            //System.IO.File.WriteAllText(Environment.CurrentDirectory + @"\dir.txt",
            //	String.Format("{0} / {1}", Environment.CurrentDirectory,
            //	System.AppDomain.CurrentDomain.BaseDirectory));

            // Handler
            // config.MessageHandlers.Add(new SimpleCorsHandler());

            // cativate CORS
            var cors = new EnableCorsAttribute(origins: "http://localhost:9999",
                                               headers: "*", methods: "*")
            {
                SupportsCredentials = true
            };

            config.EnableCors(cors);

            // further middleware ...
            app.UseWinauth();
            app.RegisterDependencies(ref config, ref builder);

            // continue OWIN pipeline (Web API)
            app.UseWebApi(ref config);
            app.UseWelcomePage();
        }
Esempio n. 31
0
 public void Configuration(IAppBuilder app)
 {
     // Any connection or hub wire up and configuration should go here
     app.UseWelcomePage("/");
     app.UseCors(CorsOptions.AllowAll);
     app.MapSignalR();
 }
Esempio n. 32
0
        public void Configuration(IAppBuilder app)
        {
            var config = new HttpConfiguration();

            // activate CORS
            var cors = new EnableCorsAttribute(
                origins: ConfigurationManager.AppSettings["MicroErpApi.AllowedOrigins"],
                headers: "*", methods: "*");

            config.EnableCors(cors);

            //Use a cookie to temporarily store information about a user logging in with
            //a third party login provider
            //app.UseExternalSignInCookie(DefaultAuthenticationTypes.ExternalCookie);

            // For JWT authentication on the resource API
            app.UseOAuthJWTAuthentication();

            // For external auth
            //app.UseOAuthBearerAuthentication();

            // For Google authentication ...
            //app.UseGoogleAuthentication();

            // For Facebook authentication ...
            //app.UseFacebookAuthentication();

            // OWIN Pipeline (Web API)
            app.UseWebApi(ref config);
            app.UseWelcomePage();
        }
Esempio n. 33
0
 public void Configuration(IAppBuilder app)
 {
     // Microsoft.Owin.Diagnostics allows for these guys:
     #if DEBUG
     app.UseErrorPage();
     #endif
     app.UseWelcomePage("/");
 }
Esempio n. 34
0
 public void Configuration(IAppBuilder app)
 {
     app.UseElmoMemoryLog();
     app.UseElmoViewer();
     //app.UseErrorPage();
     app.UseWelcomePage("/");
     app.Use(DoSomething);
 }
Esempio n. 35
0
 public void Configuration(IAppBuilder app)
 {
     app.UseElmoMemoryLog();
     app.UseElmoViewer();
     //app.UseErrorPage();
     app.UseWelcomePage("/");
     app.Use(DoSomething);
 }
Esempio n. 36
0
 public void Configuration(IAppBuilder app)
 {
     app.Frameguard(XFrameOptions.Deny);
     app.XssFilter(true);
     app.NoSniff();
     app.IENoOpen();
     app.UseWelcomePage();
 }
 public void Configuration(IAppBuilder appBuilder)
 {
     HttpConfiguration config = new HttpConfiguration();
     WebApiConfig.Register(config);
     IdleTimeoutHandler.Register(config);
     appBuilder.UseWebApi(config);
     appBuilder.UseErrorPage();
     appBuilder.UseWelcomePage("/");
 }
Esempio n. 38
0
        public void Configuration(IAppBuilder app)
        {
#if DEBUG
            app.UseErrorPage();
#endif
            app.UseWelcomePage("/");

            GlobalConfiguration.Configuration.UseMemoryStorage();
        }
Esempio n. 39
0
 public void Configuration(IAppBuilder app)
 {
     app.UseErrorPage();             // See Microsoft.Owin.Diagnostics
     app.UseWelcomePage("/Welcome"); // See Microsoft.Owin.Diagnostics
     app.Run(async context =>
     {
         await context.Response.WriteAsync("Hello world using OWIN TestServer");
     });
 }
Esempio n. 40
0
 public void Configuration(IAppBuilder appBuilder)
 {
     HttpConfiguration config = new HttpConfiguration();
     WebApiConfig.Register(config);
     appBuilder.UseWebApi(config);
     config.Formatters[0] = new JsonStringMediaTypeFormatter();
     appBuilder.UseErrorPage();
     appBuilder.UseWelcomePage("/");
 }
Esempio n. 41
0
 public void Configuration(IAppBuilder app)
 {
     app.UseErrorPage(); // See Microsoft.Owin.Diagnostics
     app.UseWelcomePage("/Welcome"); // See Microsoft.Owin.Diagnostics 
     app.Run(async context =>
     {
         await context.Response.WriteAsync("Hello world using OWIN TestServer");
     });
 }
Esempio n. 42
0
        public void Configuration(IAppBuilder app)
        {
            #if DEBUG
            app.UseErrorPage();
            #endif
            app.UseWelcomePage("/welcome");

            app.Use(async (ctx, next) =>
            {
                Debug.WriteLine("IN - [{0}] {1}{2}", ctx.Request.Method, ctx.Request.Path, ctx.Request.QueryString);
                await next();
                if (ctx.IsHtmlResponse()) await ctx.Response.WriteAsync("Added at bottom will be moved into body by good browser");
                Debug.WriteLine("OUT - " + ctx.Response.ContentLength);
            });

            app.UseDebugMiddleware(new DebugMiddlewareOptions
            {
                OnIncomingRequest = ctx =>
                {
                    var watch = new Stopwatch();
                    watch.Start();
                    ctx.Environment["DebugStopwatch"] = watch;
                },
                OnOutgoingRequest = ctx =>
                {
                    var watch = (Stopwatch)ctx.Environment["DebugStopwatch"];
                    watch.Stop();
                    Debug.WriteLine("Request took: " + watch.ElapsedMilliseconds + " ms");
                }
            });

            app.Map("/mapped", map => map.Run(ctx =>
                {
                    ctx.Response.ContentType = "text/html";
                    return ctx.Response.WriteAsync("<html><body>mapped</body></html>");
                }));
           
            //app.UseBeanMiddleware();
            //app.Use(async (ctx, next) =>
            //{
            //    if (ctx.Authentication.User != null &&
            //        ctx.Authentication.User.Identity != null &&
            //        ctx.Authentication.User.Identity.IsAuthenticated)
            //    {
            //        await next();
            //    }
            //    else
            //    {
            //        ctx.Authentication.Challenge(AuthenticationTypes.Federation);
            //    }
            //});

            app.UseCornifyMiddleware(new CornifyMiddlewareOptions { Autostart = false });
            app.UseKonamiCodeMiddleware(new KonamiCodeMiddlewareOptions { Action = "setInterval(function(){ cornify_add(); },500);" });

            app.UseServeDirectoryMiddleware();
        }
Esempio n. 43
0
        public void Configuration(IAppBuilder app)
        {
            Metric.Config
            .WithOwin(m => app.Use(m), c => c.WithMetricsEndpoint());

            app.UseWelcomePage();

            // For more information on how to configure your application, visit http://go.microsoft.com/fwlink/?LinkID=316888
        }
Esempio n. 44
0
 public void Configuration(IAppBuilder app)
 {
     app.UseWelcomePage();
       //TODO: LLegamos hasta The AppFunc del curso "ASP.NET MVC 5 Fundamentals" http://pluralsight.com/training/Player?author=scott-allen&name=aspdotnet-mvc5-fundamentals-m3-identity&mode=live&clip=0&course=aspdotnet-mvc5-fundamentals
       //app.Run(ctx =>
       //{
       //  return ctx.Response.WriteAsync("Hello World!");
       //});
 }
Esempio n. 45
0
        public void Configuration(IAppBuilder app)
        {
            app.UseWelcomePage("/");
            app.UseCors(CorsOptions.AllowAll);
            var config = new HttpConfiguration();

            ConfigureWebApi(config);
            app.UseWebApi(config);
        }
Esempio n. 46
0
        /// <summary>
        /// Configures the OWIN runtime
        /// </summary>
        /// <param name="app">The application builder</param>
        public void Configuration(IAppBuilder app)
        {
            app.UseOAuthAuthorizationServer(BlobstoreConfiguration.CreateAuthorizationOptions());
            app.UseOAuthBearerAuthentication(BlobstoreConfiguration.CreateAuthenticationOptions());
            app.UseNinjectMiddleware(BlobstoreConfiguration.CreateKernel);

            app.UseNinjectWebApi(BlobstoreConfiguration.CreateHttpConfiguration());
            app.UseWelcomePage();
        }
Esempio n. 47
0
 public void Configuration(IAppBuilder app)
 {
     //for commit
     /// from shaurya master
     Console.WriteLine("test");
     app.UseWelcomePage();
     // this commit is for merge request
     // Change story 1 & =
 }
Esempio n. 48
0
        public void Configuration(IAppBuilder app)
        {
            app.UseWelcomePage("/");

            HttpConfiguration httpConfig = new HttpConfiguration();

            ConfigureWebApi(httpConfig);

            app.UseWebApi(httpConfig);
        }
Esempio n. 49
0
 public void Configuration(IAppBuilder app)
 {
     // For more information on how to configure your application, visit http://go.microsoft.com/fwlink/?LinkID=316888
     #if DEBUG
     app.UseErrorPage();
     #endif
     app.UseWelcomePage("/");
     app.UseStaticFiles();
     //app.UseWebPages();
 }
Esempio n. 50
0
        public void Configuration(IAppBuilder app)
        {
            app.UseErrorPage();
            app.UseWelcomePage("/");

            // For more information on how to configure your application, visit http://go.microsoft.com/fwlink/?LinkID=316888
            app.UseHangfire(config =>
            {
                config.UseSqlServerStorage("DefaultConnection");
                config.UseServer();
            });
        }
Esempio n. 51
0
        public void Configuration(IAppBuilder app)
        {
            app.UseErrorPage();
            app.Map("/statuscodes", statusapp =>
            {
                KittenStatusCodeOptions kittenOptions = new KittenStatusCodeOptions();
                statusapp.UseKittenStatusCodes(kittenOptions);
                statusapp.Run(new StatusCodePage(kittenOptions).Invoke);

            });
            app.UseWelcomePage();
        }
Esempio n. 52
0
        public void Configuration(IAppBuilder app)
        {
            var config = new HttpConfiguration();
            config.MapHttpAttributeRoutes();
            config.Routes.MapHttpRoute(
                name: "DefaultApi",
                routeTemplate: "api/{controller}/{id}",
                defaults: new { id = RouteParameter.Optional }
            );

            app.UseWebApi(config);
            app.UseWelcomePage();
        }
Esempio n. 53
0
        public void Configuration(IAppBuilder app)
        {
            // Configure web api routing
            var config = new HttpConfiguration();
            config.MapHttpAttributeRoutes();
            config.Routes.MapHttpRoute(
                "DefaultApi",
                "api/{controller}/{id}",
                new { id = RouteParameter.Optional });
            app.UseWebApi(config);

            // Add welcome page
            app.UseWelcomePage();
        }
Esempio n. 54
0
        public void Configuration(IAppBuilder app)
        {
            // Configure web api routing
            var config = new HttpConfiguration();
            config.Routes.MapHttpRoute("DefaultApi", 
                "api/{controller}/{id}", 
                new { id = RouteParameter.Optional });

            // Use Web API middleware
            app.UseWebApi(config);

            // Display nice welcome page
            app.UseWelcomePage();
        }
Esempio n. 55
0
        public void Configuration(IAppBuilder app)
        {
            // Use oauth authz server to issue tokens
            app.UseOAuthAuthorizationServer(new OAuthAuthorizationServerOptions
            {
                AllowInsecureHttp = true, // Set to false for production
                TokenEndpointPath = new PathString("/token"),
                AccessTokenExpireTimeSpan = TimeSpan.FromHours(8),
                Provider = new DemoAuthorizationServerProvider(Validator)
            });

            // Add error, welcome pages
            app.UseErrorPage();
            app.UseWelcomePage();
        }
Esempio n. 56
0
        /// <summary>
        /// Install-Package Microsoft.Owin.Diagnostics
        /// </summary>
        public void Configuration(IAppBuilder app)
        {
            var config = new HttpConfiguration();

            config.Routes.MapHttpRoute(
                         name: "DefaultApi",
                         routeTemplate: "api/{controller}/{id}",
                         defaults: new { id = RouteParameter.Optional }
                     );

            app.UseWebApi(config);

            // Microsoft.Owin.Diagnostics
            app.UseWelcomePage("/");
        }
Esempio n. 57
0
        public void Configuration(IAppBuilder app)
        {
            app.UseErrorPage();
            app.UseWelcomePage("/");
            app.UseHangfire(config =>
            {
                var options = new SqlServerStorageOptions { QueuePollInterval = TimeSpan.FromSeconds(1) };
                config.UseSqlServerStorage("DataContext", options).UseMsmqQueues(@".\private$\hangfire-0");
                config.UseServer();
            });

            RecurringJob.AddOrUpdate(() => CleanJob.Execute(), System.Configuration.ConfigurationManager.AppSettings["CleanJobSchedule"]);
            RecurringJob.AddOrUpdate(() => LogsCompactionJob.Execute(), System.Configuration.ConfigurationManager.AppSettings["LogCompactionJobSchedule"]);
            RecurringJob.AddOrUpdate(() => PackageCleanupJob.Execute(), System.Configuration.ConfigurationManager.AppSettings["PackageCleanupJob"]);
        }
Esempio n. 58
0
        public void Configuration(IAppBuilder app)
        {
            GlobalConfiguration.Configuration.Formatters.Add(new HtmlMediaTypeViewFormatter());

            GlobalViews.DefaultViewParser = new RazorViewParser();
            GlobalViews.DefaultViewLocator = new RazorViewLocator();

            var config = new HttpConfiguration();
            config.Routes.MapHttpRoute("default", "{controller}");
            config.Formatters.Add(new HtmlMediaTypeViewFormatter());

            app.UseWebApi(config);

            app.UseWelcomePage();
        }