Directory Access

  • Thread starter Thread starter Len Svitenko
  • Start date Start date
L

Len Svitenko

I have a site in asp.net. In that site I have a directory full of
excel spreadsheets. When a user logs in it points them to the
spreadsheet that I want them to see. However, if they then exit out
and go directly to the link it still re-opens the spreadsheet.

Here's what I am asking. How can I setup the spreadsheets/directory
so that you have to have logged in for the server to allow you into
the directory.

Here's the geek speak:

They login to http://www.site.com/login.aspx

That takes them to http://www.site.com/filelist.aspx where they can
open a spreadsheet located at
http://www.site.com/excel/specificfile.xls.

So how can I keep them from going to
http://www.site.com/excel/specificfile.xls without going through
http://www.site.com/login.aspx first?

Len
 
Put the spreadsheets in a private directory that cannot be directly accessed
from the web.
Then use some code similar to this:
Response.Clear();
Response.ContentType = "application/vnd.ms-excel"
Response.AddHeader("Content-Disposition","attachment;filename=myfile.xls");
Response.WriteFile("c:\MyPrivatePath\myfile.xls");

Here's more info:
http://msdn.microsoft.com/library/d...fsystemwebhttpresponseclasswritefiletopic.asp
http://www.aspnetpro.com/NewsletterArticle/2003/09/asp200309so_l/asp200309so_l.asp
 
Back
Top