I have an ASP.NET MVC Application
, which has a Logs
folder, where the log files are stored. Normally, I would access it as localhost/Logs/Log.common.txt
and see the logs. However, now I want to restrict it.
Now I have Logs controller, which has an Authorize attribute set to the Admin
only:
namespace MyApp.Controllers
{
[Authorize(Roles = "Admin")]
public class LogsController : BaseController
{
public ActionResult Index()
{
LogFile logFile = GetLogFileByName("log.Common.txt");
return View(logFile);
}
}
}
So now, if I try to go to localhost/Logs
, then I get an unauthorized access error, however, if I go directly to localhost/Logs/Log.common.txt
I still can see the file. Is there any way to disable this?