server.transfer error


S

shin

hi i have an asp.net page and i am trying to transfer control to another
asp.net page
response.redirect works fine but server.transfer gives me the foll error
why is that

System.Threading.ThreadAbortException: Thread was being aborted. at
System.Threading.Thread.AbortInternal() at
System.Threading.Thread.Abort(Object stateInfo) at
System.Web.HttpResponse.End() at
System.Web.HttpServerUtility.Transfer(String path, Boolean preserveForm) at
System.Web.HttpServerUtility.Transfer(String path) at
WebApplication1.WebForm1.cmdProceed_Click(Object sender, EventArgs e) in
e:\inetpub\wwwroot\webapplication1\addbooking.aspx.cs:line 350

private void cmdProceed_Click(object sender, System.EventArgs e)
{
try
{
saveBookingInfo();
Server.Transfer ("ProcessBooking.aspx");
//response.redirect works fine here .

}
catch(Exception ex)
{
Response.Write(ex.ToString());
}
}
 
Ad

Advertisements

M

Michael Per

This is what's supposed to happen. The main thread is getting aborted so the
new thread can start for the target page. In your catch block determine
whether you cought the ThreadAbortException and if yes throw it again.
Everything should work after that.
 
S

shin

hi i simply removed the try - catch and it worked.
but im not sure if this is the right way to do this.

thanx

now my problem is
1. i was trying to pass a dataset between pages. (using code-behind files)
and it works.. but i read on msdn that i need to create a dll (maybe it is
used while deploying)
and i get the foll error

csc /out:Bin\CarRentalWebApp.dll /r:System.dll /r:System.Web.dll /t:library
AddBooking.aspx.cs ProcessBooking.aspx.cs
when i do this it gives me the foll error
AddBooking.aspx.cs(12,23): error CS0234: The type or namespace name
'localhost'
does not exist in the class or namespace 'WebApplication1' (are you
missing an assembly reference?)

localhost is referencing my local webservice.

what should i do?

2. also i read in
http://msdn.microsoft.com/library/d...conpassingservercontrolvaluesbetweenpages.asp

that i can use inline code to transfer my dataset but i dont know how to use
the dataset namespace in my aspx file
<%@ Page language="c#" Codebehind="ProcessBooking.aspx.cs"
AutoEventWireup="false" Inherits="WebApplication1.ProcessBooking" %>
<%@ Reference Page="AddBooking.aspx"
using System.Data.SqlClient%>

i tried using System.Data.SqlClient, but that gives me errors.

thanx
 
Ad

Advertisements

J

Jerry III

I can answer why Server.Transfer (and Response.End) will not work inside a
checked block - it's because those two methods throw an exception to end the
current page execution. If you catch it the Asp.Net framework will never
know about it...

As for the error - I think you wanted to use localhost in a string, as in an
Url, not as a variable/namespace name. Of course it would be much easier if
I didn't have to guess what's on that line that triggers the error...

Jerry
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top