473,414 Members | 1,723 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,414 software developers and data experts.

Response.Redirect problem

I'm trying to figure out what I have wrong in the following code. It's
located at http://www.ledet.com/locations/location.aspx

If I call this page with http://www.ledet.com/locations/location.aspx?id=0
it works fine and redirects to the default page for that directory.
But if I call it with http://www.ledet.com/locations/location.aspx?id=188
it doesn't redirect

Does anyone have any suggestions?

----------------------------------------------------------------------------------------------------------

// Get locationID variable from the querystring. If there is now id
variable, redirect back to the main location page.
this.locationID = this.Request.QueryString.Get("id") != null ?
Convert.ToInt32(this.Request.QueryString.Get("id") ) : 0;
if (this.locationID == 0)
{
this.Response.Redirect("default.aspx");
}

if (this.locationID==188)
{
this.Response.Redirect("http;//www.ledet.com/vilt/default.aspx");
}

Jul 21 '07 #1
6 3163
sjledet wrote:
I'm trying to figure out what I have wrong in the following code. It's
located at http://www.ledet.com/locations/location.aspx

If I call this page with http://www.ledet.com/locations/location.aspx?id=0
it works fine and redirects to the default page for that directory.
But if I call it with http://www.ledet.com/locations/location.aspx?id=188
it doesn't redirect
What does it do, then?
Does anyone have any suggestions?

----------------------------------------------------------------------------------------------------------

// Get locationID variable from the querystring. If there is now id
variable, redirect back to the main location page.
this.locationID = this.Request.QueryString.Get("id") != null ?
Convert.ToInt32(this.Request.QueryString.Get("id") ) : 0;
if (this.locationID == 0)
{
this.Response.Redirect("default.aspx");
}

if (this.locationID==188)
{
this.Response.Redirect("http;//www.ledet.com/vilt/default.aspx");
That should be "http:", not "http;".
}

--
Göran Andersson
_____
http://www.guffa.com
Jul 21 '07 #2
Fixed the typo. Same behavior. What it does is just execute the rest
of the page with locationID as 188. It executes the SQL statement
based on that parameter later and returns the records associated with
location ID 188.

For reference, the declaration for the variable is:

protected int locationID, i;

just n case that matters

I had tried doing it relative and then tried the full path, but the
fact that it didn't error out proves it wasn't getting called.

Is it something in the syntax of:

this.locationID = this.Request.QueryString.Get("id") != null ?
Convert.ToInt32(this.Request.QueryString.Get("id") ) : 0;

Jul 21 '07 #3
sjledet wrote:
Fixed the typo. Same behavior. What it does is just execute the rest
of the page with locationID as 188. It executes the SQL statement
based on that parameter later and returns the records associated with
location ID 188.

For reference, the declaration for the variable is:

protected int locationID, i;

just n case that matters

I had tried doing it relative and then tried the full path, but the
fact that it didn't error out proves it wasn't getting called.

Is it something in the syntax of:

this.locationID = this.Request.QueryString.Get("id") != null ?
Convert.ToInt32(this.Request.QueryString.Get("id") ) : 0;
I don't see anything in your code that is wrong. You have to do some
debugging to find out what's really happening in the code.

You can skip the check for null, though, as Convert.ToInt32(string)
already does that and returns zero if the argument is null.

locationID = Convert.ToInt32(this.Request.QueryString["id"]);

--
Göran Andersson
_____
http://www.guffa.com
Jul 21 '07 #4
On Jul 21, 3:35 pm, sjledet <sjle...@gmail.comwrote:
Fixed the typo. Same behavior. What it does is just execute the rest
of the page with locationID as 188. It executes the SQL statement
based on that parameter later and returns the records associated with
location ID 188.

For reference, the declaration for the variable is:

protected int locationID, i;

just n case that matters

I had tried doing it relative and then tried the full path, but the
fact that it didn't error out proves it wasn't getting called.

Is it something in the syntax of:

this.locationID = this.Request.QueryString.Get("id") != null ?
Convert.ToInt32(this.Request.QueryString.Get("id") ) : 0;
when you are debugging this guy, what does locationID look like when
it comes out of that check? When you pass in 188 in your query
string, do you get 188 out? Also what happens if you cahnge your
statement to:

locationID = int.Parse(Request.QueryString.Get("id));

I know that that is a dumb/dangerous cast but I am guessing that
Convert.ToInt32 is giving you back something other than 0 when you
pass 188.

Jul 23 '07 #5
On Jul 21, 12:34 pm, sjledet <sjle...@gmail.comwrote:
>
Does anyone have any suggestions?
Response Redirect the way you are using it here should redirect the
page, but will do so only AFTER the rest of the page code has
completed executing. Depending on how the rest of the code is
written this could be your problem since some techniques can negate
the redirect. There is a simple solution you can try to see if this
might be the case.

Assuming that your location id is being retreived from the Querystring
correctly and you are executing the redirect logic inside the IF
statement (which all seems to be valid), try using the following
overload for your redirect statement (note changing the semi-colon ';'
typo after the HTTP to a colon ':' as well):

this.Response.Redirect("http://www.ledet.com/vilt/
default.aspx", true);

The boolean parameter TRUE after the URL indicates execution of the
current code should terminate immediately and the redirection should
occur at that time and not wait for the rest of the code to process
(FALSE is the default value if a parameter is not supplied). If your
problem is caused by the rest of the code executing, this should take
care of it.

Jul 23 '07 #6
of****@doitsolutions.com wrote:
On Jul 21, 12:34 pm, sjledet <sjle...@gmail.comwrote:
>Does anyone have any suggestions?

Response Redirect the way you are using it here should redirect the
page, but will do so only AFTER the rest of the page code has
completed executing.
Sorry, but that is not correct.

For that to happen you would have to call Response.Redirect(url, false).
Depending on how the rest of the code is
written this could be your problem since some techniques can negate
the redirect. There is a simple solution you can try to see if this
might be the case.

Assuming that your location id is being retreived from the Querystring
correctly and you are executing the redirect logic inside the IF
statement (which all seems to be valid), try using the following
overload for your redirect statement (note changing the semi-colon ';'
typo after the HTTP to a colon ':' as well):

this.Response.Redirect("http://www.ledet.com/vilt/
default.aspx", true);

The boolean parameter TRUE after the URL indicates execution of the
current code should terminate immediately and the redirection should
occur at that time and not wait for the rest of the code to process
(FALSE is the default value if a parameter is not supplied
No, it's not.

Here is the actual code from the HttpResponse class in system.web.dll:

public void Redirect(string url)
{
this.Redirect(url, true);
}
>). If your
problem is caused by the rest of the code executing, this should take
care of it.
--
Göran Andersson
_____
http://www.guffa.com
Jul 23 '07 #7

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

Similar topics

2
by: simon | last post by:
Hello All, I have an ASP application that works perfectly on our development server, but when we moved the app to our test server, I got the following error message at the line where I do...
1
by: Ken_wdh | last post by:
Dear all I have a problem, could you please give me some suggestion The problem is There is one web application that provide API to other application, you can call the api through url, for...
3
by: Gary | last post by:
I am having a strange problem that I cannot solve. I have an asp page that I use for a user to login and gain access to other pages. When the user logs in I set a couple of session variables like...
0
by: Volkan Karaboğa | last post by:
Hi all... I have an interesting problem with response.redirect func. I have used this statement to locate other pages in my app. but It doesnt work on win2003 server and framework 1.1.4322 but it...
2
by: Oney | last post by:
I send a popup to client then I redirect to the main page but the popup doesn't raise. If I comments the Response.Redirect line the popup is raised How can I solve this problem??? thanks ...
3
by: alasdair.stirling | last post by:
Dear All, I am new to ASP/ASP.Net and am trying to workout the exact meaning of some old ASP Classic code. Can anyone please explain the meaning of the following line of code: ...
3
by: new214 | last post by:
heya all, ive got abit of a problem. Im doin a system in asp- which works on a test server- but when on moving my application to a development server- it throws the following error messages where I...
2
by: rajarameshvarma | last post by:
Hi, I have developed a custom HttpModule in my application. When ever user requests some specific pages i am transering redirecting them to some other pages. It is not possible to add...
4
by: JDS | last post by:
I am a newbie to asp.net but have done traditional vb, asp and vb.net - please forgive any dumb questions! As a test I have a very simple page (Default.aspx) with a single button which then...
0
by: Lasse Edsvik | last post by:
Hello I have a strange problem, I'm using Debitech for a system that handles payments. And I have this Response.Redirect(https://long address) that is sent to their server with a long...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
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...
0
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,...
0
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...

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.