public DefaultController(ILog log, IGreeter greeter) { Contract.Requires<ArgumentNullException>(log != null); Contract.Requires<ArgumentNullException>(greeter != null); Contract.Ensures(Log != null); Contract.Ensures(Greeter != null); Log = log; Greeter = greeter; }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env, IGreeter greeter) { app.UseRuntimeInfoPage("/info"); if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } app.UseFileServer(); app.UseMvc(ConfigureRoutes); app.Run(async (context) => { var greeting = greeter.GetGreeting(); await context.Response.WriteAsync(greeting); }); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory, IGreeter greeter) { loggerFactory.AddConsole(); if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } app.UseFileServer(); app.UseMvc(ConfigureRoutes); app.Run(context => context.Response.WriteAsync("Not found")); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment environment, IGreeter greeter) { // Keep in mind that the order of which middlewares are installed matter. // The IIS Platform middleware looks at every incoming request and see if there's any windows // identity information associated with the request. app.UseIISPlatformHandler(); if (environment.IsDevelopment()) { app.UseDeveloperExceptionPage(); } app.UseRuntimeInfoPage("/info"); //// The Static Files middleware find files on the file system and serve up those files.If it //// doesn't find a file, it will move on to the next piece of middleware. // app.UseStaticFiles(); //// What use default files middleware does is see if it's in a root directory and if it is //// then it looks to see if there are any default files.If we want we could overwrite by telling //// it which files are the default files.For example, index.html is a default file by default. // app.UseDefaultFiles(); //app.UseFileServer(); // The MVC middleware is usually placed after any other middleware that serves up static files. // app.UseMvcWithDefaultRoute(); // The Run middleware allows us to pass in another method that processes every other response. // Run is called a terminal piece of middleware. Run will not be able to call another piece of // middleware. All it does is receive a request and produces a piece of response. Any other // middleware called after Run will not run because Run is terminal. app.Run(async (context) => { var greeting = greeter.GetGreeting(); await context.Response.WriteAsync(greeting); }); }
// This method gets called by the runtime. // Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment environment, IGreeter greeter) { if (environment.IsDevelopment()) { app.UseDeveloperExceptionPage(); } app.UseRuntimeInfoPage("/info"); app.UseFileServer(); //this contains UseDefaultFiles and UseStaticFiles app.UseMvc(ConfigureRoutes); app.Run(async (context) => { //throw new System.Exception("Error!"); var greeting = greeter.GetGreeting(); //await context.Response.WriteAsync("Hello World! Life is great!"); await context.Response.WriteAsync(greeting); }); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure( IGreeter greeter, IApplicationBuilder app, IHostingEnvironment env, ILogger <Startup> logger) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } app.UseRewriter(new RewriteOptions().AddRedirectToHttpsPermanent()); app.UseStaticFiles(); app.UseNodeModules(env.ContentRootPath); app.UseScripts(env.ContentRootPath); app.UseData(env.ContentRootPath); app.UseAuthentication(); app.UseMvc(ConfigureRoutes); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env, IGreeter greeter, ILogger <Startup> logger ) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } app.UseStaticFiles(); app.UseMvc(ConfigureRoutes); app.Run(async(context) => { var greeting = greeter.GetMessageOfTheDay(); context.Response.ContentType = "text/plain"; await context.Response.WriteAsync($"Not found"); }); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IGreeter greeter, IHostingEnvironment appEnvironment) { //app.UseIISPlatformHandler(); this is now integrated into the framework app.UseDeveloperExceptionPage(); //app.UseRuntimeInfoPage("/info"); //app.UseDefaultFiles(); //app.UseStaticFiles(); app.UseFileServer(); //combines the 2 above app.UseNodeModules(appEnvironment); app.UseIdentity(); app.UseMvc(ConfigureRoutes); //app.Run is like a "terminal" peice of middleware. no middleware written after this will run app.Run(async (context) => { //throw new Exception("Error!"); var greeting = greeter.GetGreeting(); await context.Response.WriteAsync(greeting); }); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env, IGreeter greeter) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } app.UseRuntimeInfoPage("/info"); app.UseFileServer(); app.UseNodeModules(env); app.UseIdentity(); app.UseMvc(ConfigureRoutes); app.Run(async(context) => { var greeting = greeter.GetGreeting(); await context.Response.WriteAsync(greeting); }); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory, IGreeter greeter) { //loggerFactory.AddConsole(); loggerFactory.AddConsole(Configuration.GetSection("Logging")); loggerFactory.AddDebug(); if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } else { app.UseExceptionHandler("/Home/Error"); } //app.UseStatusCodePages(); //app.UseDefaultFiles(); app.UseStaticFiles(); //app.UseFileServer(); app.UseMvc(routes => { routes.MapRoute( name: "default", template: "{controller=Home}/{action=Index}/{id?}"); }); app.Run(async(context) => { var greeting = Configuration["greeting"]; greeting = greeter.GetGreeting(); await context.Response.WriteAsync(greeting); }); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure( IApplicationBuilder app, IGreeter greeter, IHostingEnvironment env, ILoggerFactory loggerFactory) { loggerFactory.AddConsole(); if (env.IsDevelopment()) { //middleware 1 app.UseDeveloperExceptionPage(); } //must come after static files //app.UseDefaultFiles(); //app.UseStaticFiles(); //combine usedefault files and use static files app.UseFileServer(); app.UseMvcWithDefaultRoute(); //app.UseWelcomePage(); //middleware RUN - terminal piece of middleware- won't call another middleware //buck stops here! //RUN middleware is rare, mostly USE middleware app.Run(async(context) => { //throw new System.Exception("Error here!"); //var greeting = Configuration["greeting"]; var greeting = greeter.GetGreeting(); //await context.Response.WriteAsync("Hello World and Beyond!!!"); await context.Response.WriteAsync(greeting); }); }
//- This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env, IGreeter greeter, ILogger <Startup> logger) { if (env.IsDevelopment()) { //- Use verbose exceptions when in development app.UseDeveloperExceptionPage(); } // Switch incoming requests to SSL //app.UseRewriter(new RewriteOptions().AddRedirectToHttpsPermanent()); app.UseWelcomePage(new WelcomePageOptions { Path = "/welcome" }); //- app.UseFileServer(); => combos UseDefeultFile & UseStaticFiles() //- If user directly accesses static file (e.g. /index.html), serve it, otherwise... app.UseStaticFiles(); //- Serve MVC routes //- Requires MVC service app.UseMvc(ConfigureRoutes); app.Run(async(context) => { string greeting = greeter.GetMessage(); context.Response.ContentType = "text/plain"; await context.Response.WriteAsync("Not Found"); }); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env , IGreeter greeer, ILogger <Startup> logger) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } //else //{ // app.UseExceptionHandler(); //} //app.Use(next => { // return async context => // { // logger.LogInformation("Receive request"); // if (context.Request.Path.StartsWithSegments("/mym")) // { // await context.Response.WriteAsync("ASDFASDFAAS"); // logger.LogInformation("Request handled"); // } // else // { // await next(context); // logger.LogInformation("Response outgoing"); // } // }; //}); //app.UseDefaultFiles(); app.UseStaticFiles(); app.UseMvcWithDefaultRoute(); app.Run(async(context) => { var greeting = greeer.GetMessageOfTheDay(); await context.Response.WriteAsync($"{greeting} : {env.EnvironmentName}"); }); }
// This method gets called by the runtime. // Use this method to configure the HTTP request pipeline. public void Configure( IApplicationBuilder app, IHostingEnvironment environment, IGreeter greeter) { app.UseIISPlatformHandler(); if (environment.IsDevelopment()) { app.UseDeveloperExceptionPage(); } app.UseRuntimeInfoPage("/info"); app.UseFileServer(); app.UseMvcWithDefaultRoute(); app.Run(async(context) => { var greeting = greeter.GetGreeting(); await context.Response.WriteAsync(greeting); }); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure( IApplicationBuilder app, // << Dependency injection IHostingEnvironment env, // << Dependency injection IConfiguration configuration, // << Dependency injection IGreeter greeter, // << Dependency injection ILogger <Startup> logger ) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); // Must be registered first in the pipeline } else { // app.UseExceptionHandler(); } // Use static file located in folde wwww and set up default page //app.UseDefaultFiles(); // Already to index.html, must be set before UseStaticFiles app.UseStaticFiles(); // Same as above //app.UseFileServer(); // app.UseMvcWithDefaultRoute(); << default route configured app.UseMvc(ConfigureRoutes); // For every request app.Run(async(context) => { // priority form low to high: appSettings.json, Env Var, command line parameter // dotnet.exe run Greeting="Hello from command line" var greeting = configuration["Greeting"]; greeting = greeter.GetMessageOfTheDay(); context.Response.ContentType = "text/plain"; await context.Response.WriteAsync($"Not Found - Message:{greeting} EnvironmentName:{env.EnvironmentName}"); }); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. // for every HTTP message that arrives, it's the code in this config method that defines the components that respond to that request // AKA: Processing Pipeline // Dependency Injection: Uses it here // "Use" methods: Order matters public void Configure(IApplicationBuilder app, IHostingEnvironment env, IGreeter greeter, ILogger <Startup> logger) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } // SSL-related Middleware app.UseRewriter(new RewriteOptions() .AddRedirectToHttpsPermanent()); //app.UseDefaultFiles(); // Middleware that looks inside dir and find a default file (like index.html). In paren can place default file if it's NOT index.html app.UseStaticFiles(); // Middleware that allows us to use files in wwwroot folder //app.UseFileServer(); // Does both of the things above app.UseNodeModules(env.ContentRootPath); app.UseAuthentication(); app.UseMvc(ConfigureRoutes); }
public JsonStringFormatter(IGreeter greeter, IConfiguration configuration, ProductMeasures productMeasures , IOptions <FavOptions> favourites) { if (greeter == null) { throw new ArgumentNullException("Greeter"); } if (configuration == null) { throw new ArgumentNullException("Configuration"); } if (productMeasures == null) { throw new ArgumentNullException("Measures"); } if (favourites == null || favourites.Value == null) { throw new ArgumentNullException("Favourites"); } _greeter = greeter; _configuration = configuration; _productMeasures = productMeasures; _favOptions = favourites.Value; }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure( IApplicationBuilder app , IHostingEnvironment env, IGreeter greeter ) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } else { app.UseExceptionHandler(new ExceptionHandlerOptions { ExceptionHandler = context => context.Response.WriteAsync("Oops!") }); } app.UseFileServer(); app.UseMvc(ConfigureRoutes); app.Run(ctx => ctx.Response.WriteAsync("Not Found")); }
// This method gets called by the runtime. //Use this method to configure the HTTP request pipeline. public void Configure( IApplicationBuilder app, IHostingEnvironment environment, IGreeter greeter) { app.UseIISPlatformHandler(); if (environment.IsDevelopment()) { app.UseDeveloperExceptionPage(); } else { //production app.UseRuntimeInfoPage("/info"); } //app.UseDefaultFiles(); //app.UseStaticFiles(); //The above 2 lines can be replaced by app.UseFileServer(); //app.UseMvcWithDefaultRoute(); app.UseMvc(RouteConfigurations); app.Run(async(context) => { //throw new Exception("Error!"); var greeting = greeter.GetGreeting(); await context.Response.WriteAsync(greeting); }); }
public void Configure(IApplicationBuilder app, IHostingEnvironment env, IGreeter greeter, ILoggerFactory loggerFactory) { loggerFactory.AddFile($"Logs/bportfolio-{DateTime.Now.Date.ToString("MM-dd-yyyy")}.txt", LogLevel.Error); loggerFactory.AddConsole(Configuration.GetSection("Logging")); if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); app.UseBrowserLink(); } else { app.UseRewriter(new RewriteOptions() .Add(new RedirectWwwRule()) .AddRedirectToHttps() .AddRedirect(@"^section1/(.*)", "new/$1", (int)HttpStatusCode.Redirect) .AddRedirect(@"^section/(\\d+)/(.*)", "new/$1/$2", (int)HttpStatusCode.MovedPermanently) .AddRewrite("^feed$", "/?format=rss", skipRemainingRules: false)); app.UseExceptionHandler("/Home/Error"); } app.UseFileServer(); app.UseMvc(routes => { routes.MapRoute( name: "default", template: "{controller=Home}/{action=Index}/{id?}"); }); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. //Configures the http processing pipeline, for every request this defines how to respond to that request //The parameters in this method is a type of dependency injection. ASP.NET use the parameters and will pass in an //object or service that implements those interfaces //This is where all the middleware is stored public void Configure(IApplicationBuilder app, IHostingEnvironment env, IGreeter greeter) { //if (env.IsDevelopment()) //{ // app.UseDeveloperExceptionPage(); //} //If there are no arguments in this call the order of middleware matters in this case //as the useWelcomepage middleware responds to every request any //middleware underneath it becomes unreachable //app.UseWelcomePage( new WelcomePageOptions //{ // Path="/wp" //}); app.UseStaticFiles(); app.UseMvc(ConfigureRoutes); app.Run(async(context) => { var greeting = greeter.GetMessageOfTheDay(); await context.Response.WriteAsync(greeting); }); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env, IConfiguration configuration, ILogger <Startup> logger, IGreeter greeter) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } else { app.UseExceptionHandler("/Error"); app.UseHsts(); } app.UseHttpsRedirection(); app.UseStaticFiles(); app.UseSpaStaticFiles(); app.UseMvc(routes => { routes.MapRoute( name: "default", template: "{controller}/{action=Index}/{id?}"); }); app.UseSpa(spa => { spa.Options.SourcePath = "ClientApp"; if (env.IsDevelopment()) { spa.UseReactDevelopmentServer(npmScript: "start"); } }); }
public void Configure(IApplicationBuilder app, IHostingEnvironment env, IGreeter greeter, ILogger <Startup> logger) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } // Kör sajten med HTTPS app.UseRewriter(new RewriteOptions().AddRedirectToHttpsPermanent()); app.UseStaticFiles(); app.UseAuthentication(); app.UseMvc(ConfigureRoutes); //app.Run(async (context) => //{ // var greeting = greeter.GetMessageOfTheDay(); // context.Response.ContentType = "text/plain"; // await context.Response.WriteAsync($"Not found"); //}); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILogger <Startup> logger, IGreeter greeter) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } //app.UseWelcomePage(new WelcomePageOptions() //{ // Path = "/wp" //}); app.UseStaticFiles(); app.UseMvcWithDefaultRoute(); app.Run(async(context) => { await context.Response.WriteAsync(greeter.GetMessage()); }); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env, IGreeter greeter, ILogger <Startup> logger, IConfiguration config) { // IHostingEnvironment gives you the runtime environment if (env.IsDevelopment()) { // env.ApplicationName // env.ContentRootPath // env.EnvironmentName, assess the host value of "ASPNETCORE_ENVIRONMENT" environment variable // env.IsStaging() // env.IsProduction() // env.IsEnvironment("QA") // middleware, shows developer friendly error page. app.UseDeveloperExceptionPage(); } // build my custom middle ware // app.Use only invoke once to setup the middlware // the inner return async context => {} is the middleware // which get invoked for each http request // app.Use(next => { //next is RequestDelegate, also the next middleware in the pipeline // return async context => { // logger.LogInformation("Request incoming"); // if(context.Request.Path.StartsWithSegments("/mym")) // { // await context.Response.WriteAsync("Hit!!"); // logger.LogInformation("Request handled by custom middleware"); // } // else // { // await next(context); // logger.LogInformation("Response outgoing"); // } // }; // }); //make every request serve the welcome page // app.UseWelcomePage(new WelcomePageOptions { // //url mapping just for welcom page // Path="/wp" // }); // app.UseDefaultFiles(); //set the default to index.html, order matters, set default file fist, // app.UseStaticFiles(); //use static files in wwwroot folder, order matters, use static file second // app.UseFileServer(); //this is equivalent to combine UseDefaultFiles() and UseStaticFiles() app.UseStaticFiles(); // app.UseMvcWithDefaultRoute(); app.UseMvc(configureRoutes); app.Run(async(context) => { // throw new Exception("error!"); var greetingMessage = greeter.getGreetingOfToday(); var greetingFromConfig = config["Greeting"]; // await context.Response.WriteAsync(greetingMessage); // await context.Response.WriteAsync($"{greetingMessage} : {env.EnvironmentName} : {greetingFromConfig}"); context.Response.ContentType = "text/plain"; await context.Response.WriteAsync($"Not found"); }); }
/// <summary>Creates service definition that can be registered with a server</summary> #pragma warning disable 0618 public static ServerServiceDefinition BindService(IGreeter serviceImpl) #pragma warning restore 0618 { return(ServerServiceDefinition.CreateBuilder(__ServiceName) .AddMethod(__Method_SayHello, serviceImpl.SayHello).Build()); }
public HomeController(IRestaurantData restraurantData, IGreeter greeter) { _restaurantData = restraurantData; _greeter = greeter; }
public GreeterController() { _dateTimeService = new DateTimeService(); _greeter = new Greeter(_dateTimeService); }
// creates service definition that can be registered with a server public static ServerServiceDefinition BindService(IGreeter serviceImpl) { return ServerServiceDefinition.CreateBuilder(__ServiceName) .AddMethod(__Method_SayHello, serviceImpl.SayHello).Build(); }
public HomeController(IRestaurantData restaurantData, IGreeter greeter) { this.restaurantData = restaurantData; this.greeter = greeter; }
public DependencyInjectionGreeter(IGreeter greeter) { _greeter = greeter; }
public Greeting(IGreeter greeter) { _greeter = greeter; }
public GreetingModel(IGreeter greeter) { _greeter = greeter; }
public HomeController(IRestaurantData restaurantData, IGreeter greeter) { _restaurantData = restaurantData; _greeter = greeter; }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory, IGreeter greeter) { loggerFactory.AddConsole(); if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } else { app.UseExceptionHandler(new ExceptionHandlerOptions { ExceptionHandler = context => context.Response.WriteAsync("Opps!") }); } app.UseIdentity(); app.UseMvc(); }
public GreetingModel(IGreeter greeter) { this._greeter = greeter; }
public HelloGrain(ILogger <HelloGrain> logger, IGreeter greeter) { _logger = logger; _greeter = greeter; }
public Messenger(IGreeter greeter) { _greeter = greeter; }
public GreeterController(IGreeter greeter, IDateTimeService dateTimeService) { _greeter = greeter; _dateTimeService = dateTimeService; }
public DebugOutputDisplay(IGreeter greeter) { this.Greeter = greeter; }
// previous code for in memory or non-repository pattern data // public HomeController(IRestaurantData restaurantData, IGreeter greeter) public HomeController(IOdeToFoodRepository restaurantData, IGreeter greeter) { _restaurantData = restaurantData; _greeter = greeter; }
public AppEngine(IGreeter greeter, IOutputDisplay outputDisplay) { this.greeter = greeter; this.outputDisplay = outputDisplay; }
public static SurrogateForIGreeter Convert(IGreeter value) { if (value == null) return null; return new SurrogateForIGreeter { Target = ((GreeterRef)value).Target }; }
public AppEngineTest(IGreeter greeter, IOutputDisplay output) { this._greeter = greeter; this._output = output; }
public SampleFunction(IGreeter greeter, IOptions <SampleOptions> options) { _greeter = greeter; _options = options; }
public GreetServiceWorker(IGreeter greeter) { Greeter = greeter.ThrowIfNull("greeter"); }
public GreeterViewComponent(IGreeter greeter) { _greeter = greeter; }
public GreetingsModule(IGreeter greeter) { Get["/"] = x => greeter.Greet(); }