// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IWebHostEnvironment env, DataContext dataContext) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } app.UseRouting(); app.UseMiddleware <TestMiddleware>(); app.UseEndpoints(endpoints => { endpoints.MapGet("/", async context => { await context.Response.WriteAsync("Hello World!"); }); // p439 web service using custom endpoint //endpoints.MapWebService(); // p442 web service using controller endpoints.MapControllers(); // defines routes that will allow controllers to handle requests }); app.UseSwagger(); app.UseSwaggerUI(opts => { opts.SwaggerEndpoint("/swagger/v1/swagger.json", "WebApp"); }); SeedData.SeedDatabase(dataContext); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IWebHostEnvironment env, DataContext dataContext, IAntiforgery antiforgery) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } app.UseStaticFiles(); app.UseRouting(); // p700 adding custome middleware to set the XSRF-TOKEN cookie - Http only must be set to false so browser allows Javascript code to read the cookie app.Use(async(context, next) => { if (!context.Request.Path.StartsWithSegments("/api")) { context.Response.Cookies.Append("XSRF-TOKEN", antiforgery.GetAndStoreTokens(context).RequestToken, new CookieOptions { HttpOnly = false }); } await next(); }); app.UseEndpoints(endpoints => { endpoints.MapControllers(); // defines routes that will allow controllers to handle requests endpoints.MapControllerRoute("forms", "controllers/{controller=Home}/{action=Index}/{id?}"); // page 670 endpoints.MapDefaultControllerRoute(); // sets up convention based routing endpoints.MapRazorPages(); }); SeedData.SeedDatabase(dataContext); }
public void Configure(IApplicationBuilder app, DataContext context, IAntiforgery antiforgery) { app.UseRequestLocalization(); app.UseDeveloperExceptionPage(); app.UseStaticFiles(); app.UseRouting(); app.Use(async(context, next) => { if (!context.Request.Path.StartsWithSegments("/api")) { context.Response.Cookies.Append("XSRF-TOKEN", antiforgery.GetAndStoreTokens(context).RequestToken, new CookieOptions { HttpOnly = false }); } await next(); }); app.UseEndpoints(endpoints => { endpoints.MapControllers(); endpoints.MapControllerRoute("forms", "controllers/{controller=Home}/{action=Index}/{id?}"); endpoints.MapDefaultControllerRoute(); endpoints.MapRazorPages(); }); SeedData.SeedDatabase(context); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. //public void Configure(IApplicationBuilder app, IWebHostEnvironment env) public void Configure(IApplicationBuilder app, DataContext context) { //if (env.IsDevelopment()) //{ // app.UseDeveloperExceptionPage(); //} app.UseDeveloperExceptionPage(); app.UseStaticFiles(); app.UseRouting(); app.UseMiddleware <TestMiddleware>(); app.UseEndpoints(endpoints => { endpoints.MapGet("/", async context => { await context.Response.WriteAsync("Welcome to CDub's Api Controller!\n\n"); await context.Response.WriteAsync("To see test data: http://cdub-apicontroller.azurewebsites.net/api/products" + "\n\n"); await context.Response.WriteAsync("To see the endpoints: http://cdub-apicontroller.azurewebsites.net/swagger"); }); //endpoints.MapWebService(); endpoints.MapControllers(); }); app.UseSwagger(); app.UseSwaggerUI(options => { options.SwaggerEndpoint("/swagger/v1/swagger.json", "WebApp"); }); SeedData.SeedDatabase(context); }
public void Configure(IApplicationBuilder app, DataContext context) { app.UseDeveloperExceptionPage(); app.UseStaticFiles(); app.UseRouting(); app.UseEndpoints(endpoints => { endpoints.MapControllers(); }); SeedData.SeedDatabase(context); }
public void Configure(IApplicationBuilder app, DataContext context) { app.UseDeveloperExceptionPage(); app.UseStaticFiles(); app.UseRouting(); app.UseEndpoints(endpoints => { endpoints.MapControllers(); endpoints.MapControllerRoute("Default", "{controller=Home}/{action=Index}/{id?}"); }); SeedData.SeedDatabase(context); }
public void Configure(IApplicationBuilder app, DataContext context) { app.UseDeveloperExceptionPage(); app.UseRouting(); app.UseMiddleware <TestMiddleware>(); app.UseEndpoints(endpoints => { endpoints.MapGet("/", async context => { await context.Response.WriteAsync("Hello World!"); }); endpoints.MapControllers(); }); SeedData.SeedDatabase(context); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IWebHostEnvironment env, DataContext context, IAntiforgery antiforgery) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } else { app.UseExceptionHandler("/Home/Error"); // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts. app.UseHsts(); } app.UseHttpsRedirection(); app.UseStaticFiles(); //app.UseSession(); app.UseRouting(); app.UseEndpoints(endpoints => { endpoints.MapControllers(); // endpoints.MapControllerRoute("forms","controllers/{controller=Home}/{action=Index}/{id?}"); endpoints.MapDefaultControllerRoute(); endpoints.MapRazorPages(); //app.UseMiddleware<TestMiddleware>(); //app.UseEndpoints(endpoints => { // endpoints.MapGet("/", async context => { // await context.Response.WriteAsync("Hello World!"); // }); //endpoints.MapWebService(); endpoints.MapControllerRoute("Default", "controllers/{controller=Home}/{action=Index}/{id?}"); }); //app.UseSwagger(); //app.UseSwaggerUI(options => //{ // options.SwaggerEndpoint("/swagger/v1/swagger.json", // "WebApp"); //}); SeedData.SeedDatabase(context); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IWebHostEnvironment env, DataContext dataContext) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } app.UseRouting(); app.UseMiddleware <TestMiddleware>(); app.UseEndpoints(endpoints => { endpoints.MapGet("/", async context => { await context.Response.WriteAsync("Hello World!"); }); }); SeedData.SeedDatabase(dataContext); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, DataContext context) { app.UseDeveloperExceptionPage(); app.UseRouting(); app.UseMiddleware <TestMiddleware>(); app.UseEndpoints(endpoints => { endpoints.MapGet("/", async context => { await context.Response.WriteAsync("Hello World!"); }); // endpoints.MapWebService(); endpoints.MapControllers(); }); app.UseSwagger(); app.UseSwaggerUI(options => { options.SwaggerEndpoint("/swagger/v1/swagger.json", "WebApp"); }); SeedData.SeedDatabase(context); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IWebHostEnvironment env, DataContext dataContext) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } app.UseStaticFiles(); app.UseSession(); app.UseRouting(); app.UseEndpoints(endpoints => { endpoints.MapControllers(); // defines routes that will allow controllers to handle requests endpoints.MapDefaultControllerRoute(); // sets up convention based routing endpoints.MapRazorPages(); }); SeedData.SeedDatabase(dataContext); }
// Configure the HTTP request pipeline at runtime public void Configure(IApplicationBuilder app, DataContext context) { app.UseDeveloperExceptionPage(); app.UseRouting(); // Add test middleware component to pipeline app.UseMiddleware <TestMiddleware>(); app.UseEndpoints(endpoints => { endpoints.MapGet("/", async context => { await context.Response.WriteAsync("Hello World!"); }); // Adds extension method in WebServiceEndpoint class to request pipline //endpoints.MapWebService(); // Defines routes that allow controllers to handle requests endpoints.MapControllers(); }); SeedData.SeedDatabase(context); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IWebHostEnvironment env, DataContext dbContext) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } app.UseStaticFiles(); app.UseRouting(); app.UseEndpoints(endpoints => { endpoints.MapControllers(); endpoints.MapControllerRoute("forms", "controllers/{controller=Home}/{action=Index}/{id?}"); endpoints.MapDefaultControllerRoute(); endpoints.MapRazorPages(); }); SeedData.SeedDatabase(dbContext); }