1

I use attributes in my MVC application in order to catch incoming requests and authorize the nature of them, aka the Front Controller pattern. I want to also have an attribute in my WebApi that intercepts outgoing Responses once the Server has processed the request.

I want to do this to check the Type of the object being returned by the API, to ensure there is no leaking of sensitive internal data. Whilst thorough testing should prevent this ever happening, I wanted to implement this outgoing attribute check to be doubly sure.

Are there are framework components built in to MVC to facilitate outgoing callbacks?

Many thanks for your help

1 Answer 1

1

You may want to look into DelegatingHandler

This sits outside of the MVC pipepline and can handle the HttpRequest as well as the response from your controller. This will give you the opportunity to preprocess the HttpRequest, or postprocess the Response from the controller, as well as handle HttpResponse separately from the controller's response

DelegatingHandler for response in WebApi

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.