Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2014-11-25
6
Medium Priority
?
152 Views
Last Modified: 2014-12-08
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
0
Comment
Question by:rpm
  • 4
  • 2
6 Comments
 
LVL 10

Expert Comment

by:Walter Padrón
ID: 40465554
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
0
 
LVL 1

Author Comment

by:rpm
ID: 40465575
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
0
 
LVL 10

Expert Comment

by:Walter Padrón
ID: 40465710
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

0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 10

Expert Comment

by:Walter Padrón
ID: 40465734
This is what you need using Ajax polling
http://www.binaryintellect.net/articles/fd949e1f-dab4-4a20-938b-1e84773136a2.aspx

Best regards
0
 
LVL 1

Author Comment

by:rpm
ID: 40467208
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
0
 
LVL 10

Accepted Solution

by:
Walter Padrón earned 2000 total points
ID: 40467375
1 - The javascript code can be anywhere, for faster page load put it before the end of the body section
  <script type="text/javascript">
     // code here
  </script>
</body>

Open in new window


2- use this code in your javascript
 window.location="http://www.newpage.com";

Open in new window


Best regards
0

Featured Post

Get free NFR key for Veeam Availability Suite 9.5

Veeam is happy to provide a free NFR license (1 year, 2 sockets) to all certified IT Pros. The license allows for the non-production use of Veeam Availability Suite v9.5 in your home lab, without any feature limitations. It works for both VMware and Hyper-V environments

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
Suggested Courses

824 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question