I have an ASP.NET MVC 4 application with controllers like HomeController, ContactController, etc, that matches regular websites pages (views), etc.
I do have a special controller called LogicController, in this controller I have all my business logic in the form of functions and procedures that usually return JSON objects.
I consume this logic by using jQuery Ajax calls to /Logic/FunctionName.
So for example if I want to get a list of all customers I will consume /Logic/GetCustomerList, which in turn returns a list of customers in JSON format.
$.ajax({
type: "POST",
url: "/Logic/GetCustomerList",
async: true
});
Nothing new here.
Now if in my web browser I navigate to www.mywebsite.com/Logic/GetCustomerList, I as suspected get a list of customers (JSON) rendered in the browser.
So my question is how can I protect access to this controller, so only calls from within the application (via jquery ajax) can hit the controller, but "external" or direct calls like in this case are rejected?