I have a webserver from where users can download files that are specific for each user. To be sure each user can only download its own files they must authenticate via
Set the following in your Web.config
Place the following event in your Global.asax file.
protected void Application_BeginRequest(Object sender, EventArgs e)
{
}
Now whenever you type the URl like below.
http://localhost/dir1/jack.txt
The control will always move to Application_BeginRequest event. You have Request.Url information and Current User information and you can do the validation here.
Using below code
throw new HttpException(403,"Acess Denied");
or send the user to some another page with some user friendly message.