Link protection
-
Dear All, I want to know how to protect a file from downloading if the user is not logged in;just the way its done here on codeproject? Suppose the file url is http://www.mydomain.com/photos.zip Download file Depending upon the login status it should either redirect to login page or proceed with download of the zip file, when download file link is clicked.I need the exact functionality of codeproject download feature. Thanking you all in advance.
-
Dear All, I want to know how to protect a file from downloading if the user is not logged in;just the way its done here on codeproject? Suppose the file url is http://www.mydomain.com/photos.zip Download file Depending upon the login status it should either redirect to login page or proceed with download of the zip file, when download file link is clicked.I need the exact functionality of codeproject download feature. Thanking you all in advance.
-
Have you tried setting the navigateUrl property based on the status of their login? If variable <> "your logged in value" Then Me.HyperLink1.NavigateUrl = "" End If
ublend
-
Hi, Buddy i forgot to mention earlier that the page is in Classic ASP as opposed to Asp.Net..Sorry for that. Please help.. Thanks P
I dug up an old (2002 old) classic ASP/VB site I created that required the user to enter a username and password, which is checked against the database. If they are successful, a session variable in the global.asa file is set to true. Each page checks the variable first and bounces the user if the variable returns false. Top of each page:
'Check if user is logged in
Dim LoggedIn
LoggedIn = Session("LoggedIn")
If LoggedIn <> "True" Then
Response.Redirect("login.asp")
End Ifglobal.asa
Sub Session_OnStart
'Create a Session variable to track if the user has logged in
Session("LoggedIn") = "False"
...
End SubHope this helps.
Regards, Gary
-
Hi, Buddy i forgot to mention earlier that the page is in Classic ASP as opposed to Asp.Net..Sorry for that. Please help.. Thanks P
how are you authenticating your users? - If you are using a database to store their userID and password, you could use a script like this to signify that they are authenticated: ----use your database connection then check the form data against the data in your admin table like: Dim myPW, username,mystatus username=request("username") myPW=request("myPW") Set RSlog = Server.CreateObject("ADODB.Recordset") RSlog.Open "Select * from Admin where username='"&myLogin&"' and password='"&myPW& "'", Conn, 2, 2 If not RSLog.eof or not RSLOG.eof then myStatus="IN" end if then lower in my page, where I want active links or not, I would code something like this: Response.Write ("<a href="yourURLorFilepath/" & RS("filename")& """>Link</a>") else response.write("link not available") end if Hope that helps. Happy coding
ublend
-
how are you authenticating your users? - If you are using a database to store their userID and password, you could use a script like this to signify that they are authenticated: ----use your database connection then check the form data against the data in your admin table like: Dim myPW, username,mystatus username=request("username") myPW=request("myPW") Set RSlog = Server.CreateObject("ADODB.Recordset") RSlog.Open "Select * from Admin where username='"&myLogin&"' and password='"&myPW& "'", Conn, 2, 2 If not RSLog.eof or not RSLOG.eof then myStatus="IN" end if then lower in my page, where I want active links or not, I would code something like this: Response.Write ("<a href="yourURLorFilepath/" & RS("filename")& """>Link</a>") else response.write("link not available") end if Hope that helps. Happy coding
ublend
Hi , I am using a session variable to store my login info. Actually I am looking for a solution exactly similar to what we have on this site. I dont want to display link not available. I have certain doc files,zip files for download where i would display the link something like http://www.mydomain.com/abc.doc but when the user clicks on this link i want then to be forced to login if not logged in. So the problem is how to protect any link like this? If I would have been redirecting a user to any ASP page then its very easy to check the session value and then either permit or deny, but how to check on a link which directly points to a doc file or zip file ? I hope i am not sounding like a fool :) Thanks a lot for all the help so far.