469,962 Members | 2,208 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,962 developers. It's quick & easy.

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 3558
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 discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Nedu N | last post: by
8 posts views Thread by Cathie | last post: by
9 posts views Thread by Mark | last post: by
4 posts views Thread by john | last post: by
5 posts views Thread by Guadala Harry | last post: by
11 posts views Thread by Alexander Bosch | last post: by
18 posts views Thread by UJ | last post: by
8 posts views Thread by bryan | last post: by
5 posts views Thread by Richard | last post: by
1 post views Thread by rainxy | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.