Solved

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

Posted on 2014-11-25
6
120 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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
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 500 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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Suggested Solutions

For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

746 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now