protected override void ApplicationStartup(Nancy.TinyIoc.TinyIoCContainer container, Nancy.Bootstrapper.IPipelines pipelines) { base.ApplicationStartup(container, pipelines); /*enable lightningcache using the DiskCacheStore, vary by url params id,query,take and skip*/ this.EnableLightningCache(container.Resolve <IRouteResolver>(), ApplicationPipelines, new[] { "id", "query", "take", "skip" }, new DiskCacheStore("c:/tmp/cache")); StaticConfiguration.EnableRequestTracing = true; }
protected override void ConfigureApplicationContainer(Nancy.TinyIoc.TinyIoCContainer container) { base.ConfigureApplicationContainer(container); container.Register <IBus> (CreateEasyNetQBus()); // kick off the hearbeat monitor ... container.Resolve <IHeartbeatMonitor> ().Start(); }
protected override void ApplicationStartup(Nancy.TinyIoc.TinyIoCContainer container, Nancy.Bootstrapper.IPipelines pipelines) { container.Register <ISessionFactory>((c, p) => CreateSessionFactory()); var formsAuthConfiguration = new FormsAuthenticationConfiguration() { RedirectUrl = "~/login", UserMapper = container.Resolve <IUserMapper>(), }; FormsAuthentication.Enable(pipelines, formsAuthConfiguration); base.ApplicationStartup(container, pipelines); }
protected override void ApplicationStartup(Nancy.TinyIoc.TinyIoCContainer container, Nancy.Bootstrapper.IPipelines pipelines) { base.ApplicationStartup(container, pipelines); //注册 Forms 认证 到Nancy管道 container.Register <IUserMapper, FormsUserMapper>(); var formsAuthConfiguration = new FormsAuthenticationConfiguration() { RedirectUrl = "~/Forms/Login", UserMapper = container.Resolve <IUserMapper>(), }; //启用Forms 认证 FormsAuthentication.Enable(pipelines, formsAuthConfiguration); pipelines.OnError += Error; }
protected override void ApplicationStartup(Nancy.TinyIoc.TinyIoCContainer container, Nancy.Bootstrapper.IPipelines pipelines) { base.ApplicationStartup(container, pipelines); //pipelines.EnableBasicAuthentication(new BasicAuthenticationConfiguration( // container.Resolve<IUserValidator>(), // "MyRealm"));//Basic认证添加 container.Register <IUserMapper, FormsUserMapper>();//Forms 认证 var formsAuthConfiguration = new FormsAuthenticationConfiguration() { RedirectUrl = "~/forms/login", UserMapper = container.Resolve <IUserMapper>(), }; FormsAuthentication.Enable(pipelines, formsAuthConfiguration);//启用Forms 认证 pipelines.OnError += Error; }
protected override void RequestStartup(Nancy.TinyIoc.TinyIoCContainer container, Nancy.Bootstrapper.IPipelines pipelines, NancyContext context) { base.RequestStartup(container, pipelines, context); pipelines.AfterRequest.AddItemToEndOfPipeline(ctx => ctx.Response.Headers.Add("X-FRAME-OPTIONS", "DENY")); Csrf.Enable(pipelines); var formsConfig = new FormsAuthenticationConfiguration() { RedirectUrl = "~/autenticar", UserMapper = container.Resolve <IUserMapper>() }; FormsAuthentication.Enable(pipelines, formsConfig); }
protected override void ApplicationStartup(Nancy.TinyIoc.TinyIoCContainer container, Nancy.Bootstrapper.IPipelines pipelines) { //initialize my Solr service Console.WriteLine("Initializing Solr Search Service"); Startup.Init <Quote>("http://localhost:8983/solr/historicalQuotes"); Startup.Init <Hitter>("http://localhost:8983/solr/baseball"); Console.WriteLine("Search service initialized"); //register some non-discoverable dependencies container .Register <IQuoteRepository>(new QuoteRepository(ServiceLocator.Current.GetInstance <ISolrOperations <Quote> >())); container .Register <ICardRepository>(new CardRepository(ServiceLocator.Current.GetInstance <ISolrOperations <Hitter> >())); container.Register <IUserMapper, UserRepository>(); //configure forms authentication var formsAuthConfiguration = new FormsAuthenticationConfiguration() { RedirectUrl = "~/login", UserMapper = container.Resolve <IUserMapper>(), }; FormsAuthentication.Enable(pipelines, formsAuthConfiguration); //silly logging statements pipelines.BeforeRequest += (ctx) => { Console.WriteLine("starting up request, but set in app startup"); return(null); }; pipelines.AfterRequest += (ctx) => { Console.WriteLine("ending request, but set in app startup"); }; //wire everything else up automagically base.ApplicationStartup(container, pipelines); }
// The bootstrapper enables you to reconfigure the composition of the framework, // by overriding the various methods and properties. // For more information https://github.com/NancyFx/Nancy/wiki/Bootstrapper protected override void ApplicationStartup(Nancy.TinyIoc.TinyIoCContainer container, Nancy.Bootstrapper.IPipelines pipelines) { Conventions.ViewLocationConventions.Clear(); Conventions.ViewLocationConventions.Add((viewName, model, context) => { string viewLocation = string.Concat("Views/", viewName); if (context.ModulePath != null && context.ModulePath.StartsWith("/admin")) { viewLocation = string.Concat("Areas/Admin/Views/", viewName); } return(viewLocation); }); base.ApplicationStartup(container, pipelines); //Nancy.ViewEngines.Razor.RazorViewEngine var engine = container.Resolve <Nancy.ViewEngines.Razor.RazorViewEngine>(); }
/// <summary> /// Add Form Authentication to Bootstrap /// </summary> /// <param name="container"></param> /// <param name="pipelines"></param> protected override void ApplicationStartup(Nancy.TinyIoc.TinyIoCContainer container, Nancy.Bootstrapper.IPipelines pipelines) { base.ApplicationStartup(container, pipelines); // Enable Cookie Based Session CookieBasedSessions.Enable(pipelines); // Set Cryptography Configuration var cryptographyConfiguration = new CryptographyConfiguration( new RijndaelEncryptionProvider(new PassphraseKeyGenerator(DOLNancyWebInit.WEB_SERVER_COOKIE_CRYPT_SECRET, new byte[] { 1, 2, 3, 4, 5, 6, 7, 8 })), new DefaultHmacProvider(new PassphraseKeyGenerator(DOLNancyWebInit.WEB_SERVER_COOKIE_CRYPT_HASH_SECRET, new byte[] { 1, 2, 3, 4, 5, 6, 7, 8 }))); // Set Form Authentication Configuration var formsAuthConfiguration = new FormsAuthenticationConfiguration { CryptographyConfiguration = cryptographyConfiguration, RedirectUrl = "~/login", UserMapper = container.Resolve <IUserMapper>(), }; FormsAuthentication.Enable(pipelines, formsAuthConfiguration); }