Solved

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

Posted on 2014-11-25
6
139 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Create CentOS 7 Newton Packstack Running Keystone

A bug was filed against RDO for the installation of Keystone v3. This guide is designed to walk you through the configuration for using Keystone v3 with Packstack. You will accomplish this using various repos and the Answers file.

 
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

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

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

User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
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:…
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

631 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