Quantcast
Channel: ASP.NET Core
Viewing all articles
Browse latest Browse all 9386

Generic Web handler ashx in .net core

$
0
0

   Hi in mvc5 i have a NotificationHandler.ashx  handler and i make something 

if (context.Request.HttpMethod == "POST") { i get a json context and do something.... }
and the url is https://mysite/HttpHandler/NotificationHandler.ashx

h
ow do i make exactly the same in a Middleware handler in .net core ? My proble is the url in mvc5 i made ashx (it is url) in .net core how can
do that ?

    public class NotificationHandler    {        private readonly RequestDelegate _next;public NotificationHandler(RequestDelegate next)        {            _next = next;        }        public async Task Invoke(HttpContext httpContext)        {        if (httpContext.Request.Method == "POST"){   //do something.....i get json here        }                return _next(httpContext);
	}    }    // Extension method used to add the middleware to the HTTP request pipeline.    public static class NotificationHandlerExtensions    {        public static IApplicationBuilder UseNotificationHandler(this IApplicationBuilder builder)        {            return builder.UseMiddleware<NotificationHandler>();        }    }
I am confused because i need a url to send me cloud services json

Viewing all articles
Browse latest Browse all 9386

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>