PDA

View Full Version : Using ASP to locate documents, even if they change location


Brad
01-14-2003, 12:05 PM
Hi there,

I wondered if anyone could advise me whether it is possible for an ASP hyperlink to follow the location of a document for opening.

For example, we have a large server which is used solely for storing reference documentation.

These docs are usually accessed via a searchable web page, which lists the hyperlink for a document, and opens it upon activation.

However, if that document is moved, then obviously the hyperlink no longer works, and the document needs to be manually found and restored to its original location.

Does anyone know if there is a way of creating a hyperlink which may know where that document has gone to if moved ?

Thanks a lot, again, in advance,
Brad.

Roelf
01-14-2003, 02:17 PM
Originally posted by Brad
Does anyone know if there is a way of creating a hyperlink which may know where that document has gone to if moved ?

Thats not possible.

What you can do is create an asp page which accepts the documentname, including the original location as a querystring parameter. The page has to access the filesystem to check if it is still there, if not, do a search in the filesystem (based on the name of the document) to find it. If found, open the document, if not found: show a message

Roelf

BigDaddy
01-14-2003, 08:25 PM
Hypothetically, one could expand that search of the filesystem to include other folders, right?

So, you could get the file structure, then search each folder until you find it.

Example, if it's supposed to be in

c:/blah/blahblah/foofernargen, and it's not found, you could also do a limited search on c:/blah/blahblah or even whatever folders exist under the folder it's supposed to be in.

I guess it'd be a question of how much extra programming you'd want to do.

Roelf
01-14-2003, 08:35 PM
start in c:\ with one recursive function :D

Morgoth
01-14-2003, 10:07 PM
Very interesting.

If all files on the server are UNIQE, and all have an individual name then this is very much possible.
What you do is have a script that is for every hyperlink on your page, it also has a querystring attached it to to determan the page you want.

Then what you do is go to that page, and it will open a database with the links original position, and you have a new script (unknown how to make by me) that checks and looks if it's there, if not, then it looks for it itself (takes time) and then if it is found it will update the database and open. This saves alot of time if it looks for a specific location rather then looking for it all the time.

You also set it so it opens the one file and then STOPS looking for it, because it is found and prevents errors if you have more then one file with the same name.

You can also attach a counter for how many times that link is clicked by people.

You can also make a safety device so if anyone types in some random set a words into the query string, you check if it's in the database, if it isn't then give them an error.
It will also prevent files from being searched that aren't related to the site by not being in the database.

You should also make a safety device so that is the page is in the database, and it can't be found you tell them:
"The file/page you are looking for is unavalible at the moment, please go back, and try the link again, or notify/contact the webmaster/administrator."
"Go back and try the link again" Just incase you redirect to that page, and the querystring isn't left in the address bar.

Do you follow me? This is a great idea for a script, and I would like to try to make this myself at some time. (Not now, I am busy ;) )

BigDaddy
01-14-2003, 11:02 PM
And before long, your application will even start to think for itself...and then try to take over the world, and The Matrix will become reality!!!:eek:

whammy
01-15-2003, 12:09 AM
I like roelf's recursive idea, personally.

A wonderful example of that, even using FileSystemObject, can be found in the sticky thread "List all files in a directory" (or something like that) at the top of the ASP forum. Look for brainjar's post. :D

Roelf
01-15-2003, 08:39 AM
But Morgoth's idea of using a database, to store the new location of a document in case it is relocated and found again, is an efficient addition to the whole case

aCcodeMonkey
01-15-2003, 10:23 AM
Brad,

I've used an "obscure" OLEDB data provider to move files and track change using an XML file.

Read up on the MSDAIPP.DSO provider in MDAC 2.6 and MDAC 2.7 The provider can access file information via internet publishing services It acts just like a heirarchal recordset and can open,write,copy, move and delete files via the Internet publishing services. The sample code in the link below is a starting point.

Use the ADO Recordset, Record and Stream Objects to Open Documents (http://support.microsoft.com/default.aspx?scid=kb%3Ben-us%3B248255)

Morgoth
01-16-2003, 05:13 AM
If I had a use for this script, I would honestly put it on my list of things that need to be done. It sounds like a good idea for some sites, not mine.

Roelf
01-16-2003, 06:26 AM
Originally posted by aCcodeMonkey
can open,write,copy, move and delete files

the fso can do that too.

Roy Sinclair
01-16-2003, 04:33 PM
It's time to look at the Index Server service, it's installed with IIS on NT 4 and installed with the OS on W2K and XP. That service makes it very easy to search for documents even if they move around. The next step up is to look at the Sharepoint services which provide a lot of additional document management services.

You can access the Index Server database from ASP using SQL so it fulfills (and exceeds) the database that earlier respondants were talking about and you can search on a lot more than just the name of a file.

aCcodeMonkey
01-16-2003, 07:25 PM
Roy,
I agree.
The provider I listed actually reads the Index Server catalog. The reason I suggested it's use instead of FSO is that.
FSO has access to the whole computer's files system. If you are on a stand alone server that wouldn't be a problem. If you are on a shared server hosted by an ISP there may be isssues with a shared server.
Internet Publishing/WebDav is limited to the directories listed in the specific website's metabase. Since IIS manages each separate virtual website's security separately it is a more secu8re method of allowing controlled "file browsing".