// 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, IFirstService FirstService) { loggerFactory.AddConsole(); app.UseRewriter(new RewriteOptions() //.AddRedirect("redirect-rule/(.*)", "redirected/$1") //.AddRedirect(@"product/Create/(\d+)", "product/Details?id=$1") .AddRewrite(@"product/Create/(\d+)", "product/Details?id=$1", skipRemainingRules: true) //.AddRewrite(@"^rewrite-rule/(\d+)", "rewritten?var1=$1&var2=$2", skipRemainingRules: false) .Add(new RedirectImageRequests(".png", "/png-images"))); //.Add(new RedirectImageRequests(".jpg", "/jpg-images"))); if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } app.UseMvc(routes => { routes.MapRoute( name: "default", template: "{controller=Product}/{action=Index}/{id?}"); }); //app.Use(async (context, next) => //{ // string agent = context.Request.Headers["user-agent"].ToString(); // if (!string.IsNullOrEmpty(context.Request.QueryString.Value)) // { // context.Response.Headers.Add("X-Frame-Options", "localhost"); // //context.Response.Headers.Add("X-Content-Type-Options", configuration["CustomMessage"]); // await context.Response.WriteAsync("Query string is not allowed in Middleware pipeline"); // await next.Invoke(); // } //}); app.Map("/map1", HandleMapMiddlewareOne); app.Map("/map2", HandleMapMiddlewareTwo); //app.MapWhen(context => context.Request.QueryString.Value.Equals("DeviceId"), appBuilder => //{ // app.Run(async context => // { // await context.Response.WriteAsync("Response for devices"); // }); //}); app.MapWhen(context => context.Request.Query.ContainsKey("branch"), HandleBranch); //Commented for testing purpose only app.UseSecurityMiddleware(); app.Run(async(context) => { //throw new Exception("From Middle ware"); //string welcomeMsg = Configuration["WelcomeEquinox"]; string welcomeMsg = FirstService.WelcomeEquinox(); await context.Response.WriteAsync(welcomeMsg); //await context.Response.WriteAsync("welcomeMsg"); }); }
// GET: Default/Details/5 public ActionResult Details([FromServices] IFirstService FirstService) { _FirstService = FirstService; return(Content(_FirstService.WelcomeEquinox())); }