In Startup.cs i have a extremely simple Map
app.Map("/Home",x=>x.UseMiddlewareLogic1() );
My full code of Configure looks as shown below
public void Configure(IApplicationBuilder app)
{
app.Map("/Home",x=>x.UseMiddlewareLogic1() );
//app.UseMiddlewareLogic1();
//app.UseMiddlewareLogic2();
app.Run(async context =>
Logic3(context));
}
Logic 3 is just a response write as shown below
public async Task Logic3(HttpContext obj)
{
await obj.Response.WriteAsync("Logic 3\n");
}
The above code shows 404 not found. The middleware logic class is the standard class which comes in the visual studio template. I am using VS 2017.
public class MiddlewareLogic1
{
private readonly RequestDelegate _next;
public MiddlewareLogic1(RequestDelegate next)
{
_next = next;
}
public async Task Invoke(HttpContext httpContext)
{
await httpContext.Response.WriteAsync("This is logic123 \n");
await _next(httpContext);
}
}
// Extension method used to add the middleware to the HTTP request pipeline.
public static class MiddlewareLogic1Extensions
{
public static IApplicationBuilder UseMiddlewareLogic1(this IApplicationBuilder builder)
{
return builder.UseMiddleware<MiddlewareLogic1>();
}
}