server.transfer error

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • shin

    server.transfer error

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

    System.Threadin g.ThreadAbortEx ception: Thread was being aborted. at
    System.Threadin g.Thread.AbortI nternal() at
    System.Threadin g.Thread.Abort( Object stateInfo) at
    System.Web.Http Response.End() at
    System.Web.Http ServerUtility.T ransfer(String path, Boolean preserveForm) at
    System.Web.Http ServerUtility.T ransfer(String path) at
    WebApplication1 .WebForm1.cmdPr oceed_Click(Obj ect sender, EventArgs e) in
    e:\inetpub\wwwr oot\webapplicat ion1\addbooking .aspx.cs:line 350

    private void cmdProceed_Clic k(object sender, System.EventArg s e)
    {
    try
    {
    saveBookingInfo ();
    Server.Transfer ("ProcessBookin g.aspx");
    //response.redire ct works fine here .

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


  • Michael Per

    #2
    Re: server.transfer error

    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 ThreadAbortExce ption and if yes throw it again.
    Everything should work after that.


    Comment

    • Michael Per

      #3
      Re: server.transfer error

      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 ThreadAbortExce ption and if yes throw it again.
      Everything should work after that.


      Comment

      • shin

        #4
        Re: server.transfer error

        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\CarRent alWebApp.dll /r:System.dll /r:System.Web.dl l /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 'WebApplication 1' (are you
        missing an assembly reference?)

        localhost is referencing my local webservice.

        what should i do?

        2. also i read in


        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="Pro cessBooking.asp x.cs"
        AutoEventWireup ="false" Inherits="WebAp plication1.Proc essBooking" %>
        <%@ Reference Page="AddBookin g.aspx"
        using System.Data.Sql Client%>

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

        thanx


        Comment

        • shin

          #5
          Re: server.transfer error

          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\CarRent alWebApp.dll /r:System.dll /r:System.Web.dl l /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 'WebApplication 1' (are you
          missing an assembly reference?)

          localhost is referencing my local webservice.

          what should i do?

          2. also i read in


          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="Pro cessBooking.asp x.cs"
          AutoEventWireup ="false" Inherits="WebAp plication1.Proc essBooking" %>
          <%@ Reference Page="AddBookin g.aspx"
          using System.Data.Sql Client%>

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

          thanx


          Comment

          • Michelle

            #6
            Re: server.transfer error

            ....Try

            Sever.Transfer( "pagename", false)

            Comment

            • Michelle

              #7
              Re: server.transfer error

              ....Try

              Sever.Transfer( "pagename", false)

              Comment

              • Jerry III

                #8
                Re: server.transfer error

                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

                "shin" <asdf@hotmail.c om> wrote in message
                news:OEKBrd5lDH A.2068@TK2MSFTN GP09.phx.gbl...[color=blue]
                > 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\CarRent alWebApp.dll /r:System.dll /r:System.Web.dl l[/color]
                /t:library[color=blue]
                > 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 'WebApplication 1' (are[/color]
                you[color=blue]
                > missing an assembly reference?)
                >
                > localhost is referencing my local webservice.
                >
                > what should i do?
                >
                > 2. also i read in
                >[/color]
                http://msdn.microsoft.com/library/de...tweenpages.asp[color=blue]
                >
                > that i can use inline code to transfer my dataset but i dont know how to[/color]
                use[color=blue]
                > the dataset namespace in my aspx file
                > <%@ Page language="c#" Codebehind="Pro cessBooking.asp x.cs"
                > AutoEventWireup ="false" Inherits="WebAp plication1.Proc essBooking" %>
                > <%@ Reference Page="AddBookin g.aspx"
                > using System.Data.Sql Client%>
                >
                > i tried using System.Data.Sql Client, but that gives me errors.
                >
                > thanx
                >
                >[/color]


                Comment

                • Jerry III

                  #9
                  Re: server.transfer error

                  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

                  "shin" <asdf@hotmail.c om> wrote in message
                  news:OEKBrd5lDH A.2068@TK2MSFTN GP09.phx.gbl...[color=blue]
                  > 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\CarRent alWebApp.dll /r:System.dll /r:System.Web.dl l[/color]
                  /t:library[color=blue]
                  > 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 'WebApplication 1' (are[/color]
                  you[color=blue]
                  > missing an assembly reference?)
                  >
                  > localhost is referencing my local webservice.
                  >
                  > what should i do?
                  >
                  > 2. also i read in
                  >[/color]
                  http://msdn.microsoft.com/library/de...tweenpages.asp[color=blue]
                  >
                  > that i can use inline code to transfer my dataset but i dont know how to[/color]
                  use[color=blue]
                  > the dataset namespace in my aspx file
                  > <%@ Page language="c#" Codebehind="Pro cessBooking.asp x.cs"
                  > AutoEventWireup ="false" Inherits="WebAp plication1.Proc essBooking" %>
                  > <%@ Reference Page="AddBookin g.aspx"
                  > using System.Data.Sql Client%>
                  >
                  > i tried using System.Data.Sql Client, but that gives me errors.
                  >
                  > thanx
                  >
                  >[/color]


                  Comment

                  Working...