Narayan Sharma

Narayan Sharma

  • NA
  • 15
  • 741

Only Logged in user can access folder/file using Owin

May 28 2019 7:06 AM
Hi,
I'm stuck here how can do it. Please help me.  I'm describing in steps
 
I'm using Owin for registration and log in. 
 
 Step 1-
I have created a web Application in ASP.NET MVC just for User register and login.
 
Step 2- 
I have written some codes in registration that my code will create a folder by username which are going to register. 
 
Step 3-
Suppose Two users registered in our application and stored data into database which name is User1 and User2.
 
Step 3-
There are two folders created under root folder.
Suppose a root folder is UserFiles  
  • UserFiles/User1
  • UserFiles/User2
Step 4-
I have added user1.pdf under User1 folder.
Same as for another user user2.pdf under User2 folder.
 
Step 5-
Direct URL to access these pdf will be:
 
http://localhost:9022/UserFiles/User1/user1.pdf
 
http://localhost:9022/UserFiles/User2/user2.pdf 
 
Step 6-
The main requirement is here now:
Suppose User1 is logged in then User1 can access only own folder like below-
http://localhost:9022/UserFiles/User1/user1.pdf 
 
And also when without logged in user is hitting these URL then our system will prompt and ask for log in and redirect in our login page.
 
 

Answers (3)