473,395 Members | 1,379 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,395 software developers and data experts.

Server.Transfer in ASP.NET - weired problem

Hi All,

I am facing a typical problem in my .NET application with the pop-up script
messages. The thing is that its working fine when i run on my development
machine but not running in expected manner when i move it to Prod
environment. Please have a look at the following code snippet...

//Page name - Add.aspx

private void Page_Load(object sender, System.EventArgs e)

{

//Page load goes here --

}

private void Submit_Click(object sender, System.EventArgs e)

{
// PopUp1

if (row exists with the kay say 'ABC' in database)

{

Response.Write("<script> alert('ABCD already exists!!');</script>");

}

else

{

//code to add the row with 'ABCD' goes here

// PopUp2

Response.Write("<script> alert('ABCD added successfully!!');</script>");
//Redirected to the same page

Server.Transfer("Add.aspx");

}

}

---------

Here the problem is that when i run thei code on my dev server, while adding
the row with ABCD, it gets added succesfully and give the popup saying 'ABCD
added succesfully' and if i try to add the same row again then i get the
'ABCD already exists' message. But when i moved this dll to production box
and it is not giving me the same result. What happens while adding row with
ABCD(by clicking submit button) it adds the row and gives 'ABCD added
sucessfully' and followed by it gives 'ABCD already exists' message also. I
see that the Submit_Click procedure being triggered twice on prodution box.

The dev version in VSNET - 2003 and PORD one is higher version than this
one. Is there any poblem in Server.Transfer while redirecting to the same
page? But it works fine on Test machine. Unfortunately i am not able to
debug on the production box, since i have moved only the dll and the aspx
pages to production box.

Thanks

Nov 18 '05 #1
5 3725
WHich version of IIS You are using. In older version of IIS Server.transfer will not work.

try

Response.Redirect
Nov 18 '05 #2
Hi Nedu,
Thank you for using MSDN Newsgroup! My name is Steven, and I'll be
assisting you on this issue.
From your description, you used the "Server.Transfer" method in your
ASP.NET web application. And the web page worked well on the dev machine,
however didn't work correctly on the production server.
If there is anything I misunderstood, please feel free to let me know.
Based on my research, there does occurs some problem on the Server.Transfer
method. This method is a new method in the IIS5. Also, here are some KB
articles I've found which are focus on this problem(both in .NET 1.1 or 1.0
), there're some different causes may lead to this method's not working :

#FIX: Calling Server.Transfer Skips Execution of Custom HTTP Filters
http://support.microsoft.com/?id=814206

#FIX: Server.Transfer Does Not Invoke IsPostBack in .NET Framework 1.1
http://support.microsoft.com/default.aspx?id=821758

#Postback Event Not Called When RewritePath Uses Server.Transfer or
Server.Execute
http://support.microsoft.com/?id=817036

You may check out the above items and compare it with both of your
enviroments to see whether there're any clues. Also, since I'm not sure
about your actual enviroment, I've tested some code on my side, but haven't
repro the same problem. So I recommend that you try a simpler page which
use the "Server.Transfer" method and use the Response.Write to output some
debug infos so as to see whether there're any thing incorrect or just to
find the runtime difference between the dev server and the prod server. And
here is a page I used to test it, you may have a reference:

---------------------------------ASPX
page--------------------------------------
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<title>ServerTransfer</title>
<meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" Content="C#">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema"
content="http://schemas.microsoft.com/intellisense/ie5">
</HEAD>
<body>
<form id="Form1" method="post" runat="server">
<table width="500" align="center">
<tr>
<td>
<asp:TextBox id="txtInput" runat="server"></asp:TextBox></td>
<td>
<asp:Button id="btnSubmit" runat="server"
Text="Submit"></asp:Button></td>
</tr>
<tr>
<td><FONT face="ËÎÌå"></FONT></td>
<td></td>
</tr>
</table>
</form>
</body>
</HTML>
-------------------------------------code behind page
class------------------------------------
public class ServerTransfer : System.Web.UI.Page
{
protected System.Web.UI.WebControls.TextBox txtInput;
protected System.Web.UI.WebControls.Button btnSubmit;

private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here
Response.Write("<br>Page.IsPostBack:" + IsPostBack.ToString());
}

#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}

/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.btnSubmit.Click += new System.EventHandler(this.btnSubmit_Click);
this.Load += new System.EventHandler(this.Page_Load);

}
#endregion

private void btnSubmit_Click(object sender, System.EventArgs e)
{
if(txtInput.Text.Equals("ABCD"))
{
Response.Write("<script> alert('Can not insert ABCD!');</script>");
}
else
{
Response.Write("<script> alert('Insert successfully!!');</script>");
Server.Transfer("ServerTransfer.aspx");
}

}
}
Please try out my suggestion. If you need any help or have any new
findings, please feel free to let me know.
Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Nov 18 '05 #3
Hello Nedu,

Also, I noticed this in your post:
"The dev version in VSNET - 2003 and PORD one is higher version than this
one."

Did you install VS.NET in production machine? If yes, did you install VS
Whidbey Beta? If no, could you please tell us the environment of the
production machine, such as OS version, service pack version, .NET
framework version and etc?

By the way, please also test Response.Redirect. It needs a new request from
the client side. Server.Transfer uses the same request as the original one.

Thanks.

Best regards,
Yanhong Huang
Microsoft Community Support

Get Secure! ¨C www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

Nov 18 '05 #4
Hi Nedu,
Thanks for your followup. As for the the problem in this issue, have you
also checked out the other KB articles(on Server.Transfer not work) I
provided in the former reply? I think they may also be helpful. In
addition, if you still feel vert confused on this problem, do you think it
proper that we look for some other approachs to workaround it? If so,
please feel free to provide the detailed requirement of your problem, I'll
be willing to help you dealing with it. Thanks.

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Nov 18 '05 #5
Hi Aarti,

Thanks for your posting. As for the hotfix described in kb, I think you
need to contact the Microsoft Product Support Service for it. As mentioned
in KB:

--------------------
To resolve this problem immediately, contact Microsoft Product Support
Services to obtain the fix. For a complete list of Microsoft Product
Support Services phone numbers and information about support costs, visit
the following Microsoft Web site:
http://support.microsoft.com/default...EN-US;CNTACTMS

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

Try get the contact info first and ask for the certain hotfix from PSS.
Thanks.

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Get Preview at ASP.NET whidbey
http://msdn.microsoft.com/asp.net/whidbey/default.aspx

Nov 18 '05 #6

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

Similar topics

1
by: Nedu N | last post by:
Hi All, I am facing a typical problem in my .NET application with the pop-up script messages. The thing is that its working fine when i run on my development machine but not running in expected...
8
by: Cathie | last post by:
Hi guys, I want to do a Server.Transfer to get to a second page, so that I may retrieve variables I have set in the first page. I'm doing that with the usual Server.Transfer("pagename", true). ...
9
by: Mark | last post by:
Hello I'm trying to use a Server.Transfer in a try-catch (I cannot put it outside the Try-Catch as it is nested deep within a component that is called in a try-catch loop) The problem is that the...
4
by: john | last post by:
I have an app that uses Server.Transfer from page1 to page2. page2 needs to be able to read all the values from page1's form. The problem is, if the user clicks the back button on page2 after a...
5
by: Guadala Harry | last post by:
I've been reading up on Server.Transfer as well as doing some testing, and it appears to always raise the ThreadAbortException error. On one hand I've read a bunch of promotional-type material...
11
by: Alexander Bosch | last post by:
Hi, I'm having a problem similar to the one that's stated in this KB http://support.microsoft.com/default.aspx?scid=kb;en-us;839521 When I'm posting a page to itself with the bool value as true it...
18
by: UJ | last post by:
Folks, We provide custom content for our customers. Currently we put the files on our server and people have a program we provide that will download the files. These files are usually SWF, HTML or...
8
by: bryan | last post by:
I've got a custom HttpHandler to process all requests for a given extension. It gets invoked OK, but if I try to do a Server.Transfer I get an HttpException. A Response.Redirect works, but I really...
5
by: Richard | last post by:
I've developed a small ASPX template framework (based on Chun Li's article on CodeProject: http://www.codeproject.com/aspnet/headerfooter.asp#xx849313xx) which uses a IHttpModule to apply...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
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...

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.