473,666 Members | 2,386 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Correct way to use Response Redirect in .NET

Hello, I have an old asp page that was used to redirect users called
redirect.asp:

<code1>
<%
Option Explicit

If Request.QuerySt ring("url") <> "" Then
Response.Redire ct Request.QuerySt ring("url")
Else
Response.Redire ct ("www.examplesi te.asp")
End If
%>
</code1>
So far I have this:

<code2>
<%@ Page Language="vb" enableviewstate ="False"%>
<script runat=server>
Public Sub Page_Load()
Response.Redire ct ("http://www.tv.dlpsales lab.com/default.aspx")
End Sub
</script>
</code2>

My question is how do I use VB.NET to do this.
When I add the above code I am given an error, since I am new to VB,
can someone help advise what is the proper way to set up a
Response.Redire ct in the manner as I have done in in code1 using
VB.NET?

Thank you,
Jul 21 '05 #1
8 3196
The need for Response.Redire ct is greatly diminished in .NET. Look into
Page.IsPostBack .
"Daniel" <te**********@y ahoo.com> wrote in message
news:78******** *************** ***@posting.goo gle.com...
Hello, I have an old asp page that was used to redirect users called
redirect.asp:

<code1>
<%
Option Explicit

If Request.QuerySt ring("url") <> "" Then
Response.Redire ct Request.QuerySt ring("url")
Else
Response.Redire ct ("www.examplesi te.asp")
End If
%>
</code1>
So far I have this:

<code2>
<%@ Page Language="vb" enableviewstate ="False"%>
<script runat=server>
Public Sub Page_Load()
Response.Redire ct ("http://www.tv.dlpsales lab.com/default.aspx")
End Sub
</script>
</code2>

My question is how do I use VB.NET to do this.
When I add the above code I am given an error, since I am new to VB,
can someone help advise what is the proper way to set up a
Response.Redire ct in the manner as I have done in in code1 using
VB.NET?

Thank you,

Jul 21 '05 #2
So to clarify, how to I use Page.IsPostBack in this manner to accomplish
the same as I have done in the first bit of code?

Any help would be appreciated?

Thanks,

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 21 '05 #3
Here is a brief explanation of how and when to use...

Response.Redire ct functions in ASP.NET exactly as it did in ASP
as the intrinsic ASP objects have been carried over to ASP.NET
for backward compatibility.

Using Response.Redire ct requires two trips to the server and imposes
performance penalties and should only be used when the three
following circumstances demand its use...

1.) When redirecting to a remote server.
2.) When redirecting to a different website on the same server.
3.) When redirecting to static pages, i.e. from .asp to .htm, .aspx to .htm
or to pages generated by different application servers such as .asp to .php
and .aspx to .php.

Otherwise use the Server.Transfer method or Server.Execute as the
circumstances may require.

--
<%= Clinton Gallagher, "Twice the Results -- Half the Cost"
Architectural & e-Business Consulting -- Software Development
NET cs*********@REM OVETHISTEXTmetr omilwaukee.com
URL http://www.metromilwaukee.com/clintongallagher/

"Terry Ashley" <te**********@y ahoo.com> wrote in message
news:%2******** *******@TK2MSFT NGP11.phx.gbl.. .
So to clarify, how to I use Page.IsPostBack in this manner to accomplish
the same as I have done in the first bit of code?

Any help would be appreciated?

Thanks,

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Jul 21 '05 #4
It looks like you were trying to see if the page had ever been loaded before
(if it had, there would be a querystring value). So, in .NET we'd do:

If IsPostBack Then
Response.Redire ct Request.QuerySt ring("url")
Else
Response.Redire ct ("www.examplesi te.asp")
End If

Using Redirect only in circumstances previously posted.

"Terry Ashley" <te**********@y ahoo.com> wrote in message
news:%2******** *******@TK2MSFT NGP11.phx.gbl.. .
So to clarify, how to I use Page.IsPostBack in this manner to accomplish
the same as I have done in the first bit of code?

Any help would be appreciated?

Thanks,

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Jul 21 '05 #5
So since i am doing both 2,3 here using Response.Redire ct is the right
way to go.

So in fact this seems to work, but as far as using ASP.NET correctly is
this the proper way to format it, if so thank you very much.

<%@ Page Language="vb" enableviewstate ="False"%>
<script runat="server">
Public Sub Page_Load()

If Request.QuerySt ring("url") <> "" Then
Response.Redire ct Request.QuerySt ring("url")
Else
Response.Redire ct ("http://www.example/default.aspx")
End If

End Sub
</script>

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 21 '05 #6

Thanks for the correction, however when I link to this file from another
page, I get an error:

Compilation Error
Description: An error occurred during the compilation of a resource
required to service this request. Please review the following specific
error details and modify your source code appropriately.

Compiler Error Message: BC30800: Method arguments must be enclosed in
parentheses.

Source Error:
Line 4:
Line 5: If IsPostBack Then
Line 6: Response.Redire ct Request.QuerySt ring("url")
Line 7: Else
Line 8: Response.Redire ct
("http://www.example.com/default.aspx")

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 21 '05 #7
Thanks for your help the following code seems to achive what I am
looking for.

<code>

<%@ Page Language="vb" enableviewstate ="False"%>
<script runat="server">
Public Sub Page_Load()

If IsPostBack Then
Response.Redire ct (Request.QueryS tring("url"))
Else
Response.Redire ct ("http://www.example.com/default.aspx")
End If

End Sub
</script>

</code>

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 21 '05 #8
It just means that in .NET, you must pass method arguments in parenthesis.
Your first redirect doesn't have any parenthesis. Try this:
If IsPostBack Then
Response.Redire ct(Request.Quer yString("url"))
Else
Response.Redire ct("http://www.example.com/default.aspx")
End If

"Terry Ashley" <te**********@y ahoo.com> wrote in message
news:%2******** ********@TK2MSF TNGP11.phx.gbl. ..

Thanks for the correction, however when I link to this file from another
page, I get an error:

Compilation Error
Description: An error occurred during the compilation of a resource
required to service this request. Please review the following specific
error details and modify your source code appropriately.

Compiler Error Message: BC30800: Method arguments must be enclosed in
parentheses.

Source Error:
Line 4:
Line 5: If IsPostBack Then
Line 6: Response.Redire ct Request.QuerySt ring("url")
Line 7: Else
Line 8: Response.Redire ct
("http://www.example.com/default.aspx")

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Jul 21 '05 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
3899
by: Paul | last post by:
I'm not getting the results I want when I use Response.Redirct in a ASP page. I enter this line of code in a asp page from domain1.com. Response.Redirect "http://www.domain2.com/VDIR2/table.asp" & "?PubID=" & PubID & "&PubName=" & PubName The query string is data to open a DB. the page displays
4
14606
by: TomT | last post by:
Hi.. I'm redirecting users to another page using: response.redirect("newpage.asp") this works... But I need to add a variable to the page specified.. IE: newpage.asp?id=JobID
6
4316
by: Sam | last post by:
I have some issues with HTTP Headers and I was hoping for some pointers or references to good articles. Here is the problem. I have 6 .aspx pages, each page contains a common .ascx. This ascx serves two purposes, 1. it contains a tab strip with response.redirects to navigate to the other pages; 2. I authenticate the user by check to see if a cookie exists, if it doesn't I redirect to a login screen.
2
1446
by: darrel | last post by:
I've been struggling with a page that is set up like this: PAGE: ------------------ control 1 - reads a cookie and executes stuff based on that control 2 - reads the same cookie and can also set the value ------------------ So, the logical layout for control 2 was this:
8
340
by: Daniel | last post by:
Hello, I have an old asp page that was used to redirect users called redirect.asp: <code1> <% Option Explicit If Request.QueryString("url") <> "" Then Response.Redirect Request.QueryString("url") Else
1
1799
by: stevebremermn | last post by:
I'm working on setting up some affiliate links on a site of mine and I haven't been able to get a redirect to work. The original affiliate link looks like this: http://www.exampleurl.com/index.php?ref=10 Rather than use this link however I am wanting to redirect to specific product pages. A product page link would look like this:
5
4562
by: venner | last post by:
I'm having an issue with an ASP.NET website after upgrading to ASP.NET 2.0. The website makes use of a central authentication service (CAS) provided at the university I work for. Each page checks a session variable, and if it is not present, does a Response.Redirect to a webpage for the CAS passing a url parameter for the url to post back to. The CAS provides a page for the user to log into, validates the username and password, and then...
4
11425
by: mike.biang | last post by:
I have an ASP page that is using an XMLHTTP object to request various pages from my server. I keep a single session throughout the XMLHTTP requests by bassing the ASPSESSIONID cookie through the XMLHTTP object. However, when the page requested through the XML object makes a <%Response.Redirect()%> call, a new session is created each time. Is this a flaw in the XMLHTTP Object? How can I force the session to remain the same after a...
1
1751
by: Culley | last post by:
I've created a secure login site. Everything works fine except for one thing... the redirect. I want to redirect users to the correct page they are accessing (say they're just clicking a link they've saved to a particular page in the secure site) rather than forcing them to navigate in from a default "login successful" page. In each secure page, I have this include file: <% if Session("valid") = "" Then Response.Redirect...
1
8560
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8644
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7389
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6200
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4200
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4372
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2776
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2012
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1778
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.