Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / March 2008

Tip: Looking for answers? Try searching our database.

Redirect after 5 seconds only if bolNeedToRedirect=True ?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Jonathan - 04 Mar 2008 02:45 GMT
I want to redirect a vb.net aspx page after 5 seconds only if a variable
bolNeedToRedirect=True. This variable is determined after code sees whether
a person is logged in.

How could I achive this considering the header meta tag for redirecting
can't be switched based on a Boolean variable?
Jialiang Ge [MSFT] - 04 Mar 2008 06:07 GMT
Hello Jonathan,

There are several ways to redirect the users to another page:

Category A: redirect with html client side code:
http://vancouver-webpages.com/META/FAQ.html#redirect
A1. Location Http header
A2. Refresh meta tag
A3. <body onload="document.location='http://other.org/'">

e.g.

<SCRIPT LANGUAGE="JavaScript">
redirTime = "2";
redirURL = "http://www.microsoft.com";
function redirTimer() { self.setTimeout("self.location.href =
redirURL;",redirTime); }
</script>
<body onLoad="redirTimer()">

Category B: redirect with server side code:
e.g Response.Redirect("Otherpage.aspx");

To accomplish task that the page is redirected after 5 seconds if the user
logs in, we can do it in this way:

protected void Page_Load(object sender, EventArgs e)
{
 if ( // pass login check )
  {
      Response.Write("<script>redirTimer();</script>"); // call the
javascript to redirect the page
        // or
      Response.Redirect("Otherpage.aspx"); // redirect with server side
code.
  }
}

Hope it helps.

Regards,
Jialiang Ge (jialge@online.microsoft.com, remove 'online.')
Microsoft Online Community Support

==================================================
For MSDN subscribers whose posts are left unanswered, please check this
document: http://blogs.msdn.com/msdnts/pages/postingAlias.aspx

Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications. If you are using Outlook Express/Windows Mail, please make sure
you clear the check box "Tools/Options/Read: Get 300 headers at a time" to
see your reply promptly.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
Mark Rae [MVP] - 04 Mar 2008 09:53 GMT
> <SCRIPT LANGUAGE="JavaScript">

That is deprecated syntax - you should be encouraging people to use: <script
type="text/javascript"> instead...
http://www.w3.org/TR/html401/interact/scripts.html#h-18.2.2.1

Signature

Mark Rae
ASP.NET MVP
http://www.markrae.net

Jialiang Ge [MSFT] - 05 Mar 2008 08:19 GMT
Thank you, Mark. That is indeed a good point.

Hello Jonathan, I am sorry that I made a mistake in <SCRIPT
LANGUAGE="JavaScript">. This is a deprecated syntax as Mark said, and
please use
<script type="text/javascript"> instead.

Thanks
Jialiang Ge  (jialge@online.microsoft.com, remove 'online.')
Microsoft Online Community Support

=================================================
When responding to posts, please "Reply to Group" via your newsreader
so that others may learn and benefit from your issue.
=================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
Jialiang Ge [MSFT] - 07 Mar 2008 03:59 GMT
Hi Jonathan,

I am writing to check the status of the issue. Would you mind letting me
know the result of the suggestions? If you need further assistance, feel
free to let me know. I will be more than happy to be of assistance.

Have a great day!

Regards,
Jialiang Ge  (jialge@online.microsoft.com, remove 'online.')
Microsoft Online Community Support

=================================================
Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
msdnmg@microsoft.com.

This posting is provided "AS IS" with no warranties, and confers no rights.
=================================================
Jonathan - 07 Mar 2008 04:43 GMT
Thanks. I haven't tried it yet but:

a) I don't want any JavaScript since some people might have it disabled

b) Do you know what the VB.net code would be for the conditional timed
redirect? I appreciate that you gave me C# but I have been programming in
VB.net.

TIA

> Hi Jonathan,
>
[quoted text clipped - 17 lines]
> This posting is provided "AS IS" with no warranties, and confers no rights.
> =================================================
Jialiang Ge [MSFT] - 10 Mar 2008 06:47 GMT
Hello Jonathan,

"Delayed" page redirecting is a client side happening. Server side code is
not able to control when to redirect the page directly. It needs to write
some javascript code to client side, and let the client code finish the
redirecting.

The corresponding VB.NET code is:

Response.Write("<script>redirTimer();</script>")

(remove the ';' in the end of the C# code line)

Regards,
Jialiang Ge  (jialge@online.microsoft.com, remove 'online.')
Microsoft Online Community Support

=================================================
Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
msdnmg@microsoft.com.

This posting is provided "AS IS" with no warranties, and confers no rights.
=================================================
Jialiang Ge [MSFT] - 12 Mar 2008 06:43 GMT
Hello Jonathan,

Would you let me know the result of my suggestion of using client-side
script to do the delayed redirection? If you need further assistance,
please feel free to let me know.

Thanks
Jialiang Ge (jialge@online.microsoft.com, remove 'online.')
Microsoft Online Community Support

=================================================
When responding to posts, please "Reply to Group" via your newsreader
so that others may learn and benefit from your issue.
=================================================
This posting is provided "AS IS" with no warranties, and confers no rights.

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.