Solved

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

Posted on 2014-11-25
6
127 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
MIM Survival Guide for Service Desk Managers

Major incidents can send mastered service desk processes into disorder. Systems and tools produce the data needed to resolve these incidents, but your challenge is getting that information to the right people fast. Check out the Survival Guide and begin bringing order to chaos.

 
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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

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…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

830 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