I have inherited a existing website with a large codebase. To handle ajax requests, the site has just one file called ajax.ashx
. Inside the file is a switch statement that looks like this:
switch (_json["m"])
{
case "editDetails":
if (requestIsValid(context))
_resp = AjaxMap.editDetailsPro(_json);
break;
case "addNewContact":
if (requestIsValid(context))
_resp = AjaxMap.addNewContact(_json);
break;
// ... and so on.
}
There is about 50 different cases.
For me, this is not the natural solution - I would probably have a different handler for each group similar requests.
I haven't worked with web technology much before. Is this the usual way to do it? And if so, what are the benefits?