Web.config allow location access for specific user

后端 未结 5 1056
悲哀的现实
悲哀的现实 2020-12-31 13:30

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

5条回答
  •  自闭症患者
    2020-12-31 14:26

    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.

提交回复
热议问题