Quantcast
Channel: Web API
Viewing all articles
Browse latest Browse all 4850

what is the usage of DelegatingHandler

$
0
0

just saw a class called DelegatingHandler . please some one tell me what is the usage ofDelegatingHandler class ?

DelegatingHandler is specific to web api or it can be used for asp.net mvc too ?

just saw a code regarding usage of

public class ContentValidationHandler : DelegatingHandler
{
    private static log4net.ILog Log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);

    protected override async Task<HttpResponseMessage> SendAsync(HttpRequestMessage request,CancellationToken cancellationToken)
    {

        var response = await base.SendAsync(request, cancellationToken);

        Stream strea = new MemoryStream();
        await request.Content.CopyToAsync(strea);
        strea.Position = 0;
        StreamReader reader = new StreamReader(strea);
        String res = reader.ReadToEnd();
        Log.Info("request content: " + res);

        return response;
    }
}

what the above code is doing tell me ?

DelegatingHandlerused at client side or web api server side ?

thanks


Viewing all articles
Browse latest Browse all 4850

Trending Articles



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