Link to home
Start Free TrialLog in
Avatar of rpm
rpmFlag for United Kingdom of Great Britain and Northern Ireland

asked on

ASP.Net (VB) How to redirect to a new page one a file exists

Hi,

I have a webpage that creates a file, and then when an external process notices that file, a second file is created automatically.

Now I want the webpage to be able to poll for that file, and when it exists, redirect to a new page.

How do I do this?

Richard
Avatar of Walter Padrón
Walter Padrón
Flag of United States of America image

Richard, is not clear for me,

do you want to check for the second file  every time you load the web page (the check is on the server)
or
upload the file and then wait and poll the server until the second file was created (the check is on the client)?

Best regards
Avatar of rpm

ASKER

I think the second case is what I need.

The webpage will create file1, then file2 will be automatically created on the server (not by the webpage!)

Once file2 exists on the server, I want to redirect to another page.

Richard
I need to setup a project to test the solution  but you should try something like this

$.ajax({
    url:'http://www.example.com/somefile.ext',
    type:'HEAD',
    error: function()
    {
        //file not exists. Set a delay and try again
    },
    success: function()
    {
        //Do whatever action you need
    }
});

Open in new window

Avatar of rpm

ASKER

That looks hopeful, but I have a couple of questions:

1) Where does the $.ajax code section go? Is it within the <head>?

2) Knowing virtually nothing about ajax, how do I set the resulting action to be a page redirection, to a new page if the file is present?

Thanks,

Richard
ASKER CERTIFIED SOLUTION
Avatar of Walter Padrón
Walter Padrón
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial