In my ASP.NET MVC controller, I accept a postback call to add error logs to my log file.
[HttpPost]
[AllowAnonymous]
public JsonResult AddError(string log)
{
//add log to log file here
...
...
...
return Json(new { Code = 0 });
}
This is to allow me to add any unhandled exception in the javascript to my log file. It will help to pinpoint if any problem arises.
This is also can be used by malicious people to put some crazy logs to the log file (eg. to bombard the website).
Is there a way or a technique to prevent this (ie. only allow my javascript to add the log)?
Thanks