How would I be able to identify whether a JSON request is coming from a browser or a server? I’m developing an AJAX application where I need to block all non-browser API requests.
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
I don’t think it’s possible to really block the requests without Authentication / Authorization mechanisms but using only HTTP specification.
However, you can use the HTTP Header’s User-Agent field
http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html
And trace / filter all the requests using that field value.
I would implement it by writing the custom ActionFilter and applying it to the Controller.
Are you going to block the requests for security purpose?