Server.Transfer

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

    Server.Transfer

    I have a server.transfer question. I have a page that
    utilizes the server.transfer method. On the page that is
    transfered to - lets say page 2, I want to do another
    server.transfer . This gives me the error:
    System.InvalidC astException: Specified cast is not valid.

    What is the proper way to do this type of page
    navigation? Thanks - Drew
  • Ignacio Machin \( .NET/ C#  MVP \)

    #2
    Re: Server.Transfer

    Hi Drew,

    I just did a test with 3 pages : webform1.aspx -- > webform2.aspx --<
    webform3.aspx

    where in the Page_Load of both webform1.aspx and webform2.aspx I do a
    Server.Transfer and it worked fine, could you post part of the code where
    the exception is risen,

    Cheers,

    --
    Ignacio Machin,
    ignacio.machin AT dot.state.fl.us
    Florida Department Of Transportation

    "Drew" <anonymous@disc ussions.microso ft.com> wrote in message
    news:02ed01c3aa 1e$81d69390$a30 1280a@phx.gbl.. .[color=blue]
    > I have a server.transfer question. I have a page that
    > utilizes the server.transfer method. On the page that is
    > transfered to - lets say page 2, I want to do another
    > server.transfer . This gives me the error:
    > System.InvalidC astException: Specified cast is not valid.
    >
    > What is the proper way to do this type of page
    > navigation? Thanks - Drew[/color]


    Comment

    • Richard K Bethell

      #3
      Re: Server.Transfer

      "Drew" <anonymous@disc ussions.microso ft.com> wrote in message
      news:02ed01c3aa 1e$81d69390$a30 1280a@phx.gbl.. .[color=blue]
      > I have a server.transfer question. I have a page that
      > utilizes the server.transfer method. On the page that is
      > transfered to - lets say page 2, I want to do another
      > server.transfer . This gives me the error:
      > System.InvalidC astException: Specified cast is not valid.[/color]

      It doesn't sound like a Server.Transfer problem so much as a type conversion
      issue. By the way, I can conceive of no well-designed scenario where you
      would actually want to do this. Server.Transfer should not be used to break
      up code or control program flow - a terribly expensive way to do things. If
      you need less code in your classes, then you should either use regions, or
      abstract some of the code out to other classes.

      R/


      Comment

      • Drew

        #4
        Re: Server.Transfer

        I am away from my home computer - I'll post the code
        shortly.

        But you can do server.transfer to go to multiple pages?

        p1 -> -> p2 -> -> p3 -> -> p4

        doing a server.transfer on each one.

        Is that the proper practice for navigating web pages in c#?

        Thanks.[color=blue]
        >-----Original Message-----
        >"Drew" <anonymous@disc ussions.microso ft.com> wrote in[/color]
        message[color=blue]
        >news:02ed01c3a a1e$81d69390$a3 01280a@phx.gbl. ..[color=green]
        >> I have a server.transfer question. I have a page that
        >> utilizes the server.transfer method. On the page that[/color][/color]
        is[color=blue][color=green]
        >> transfered to - lets say page 2, I want to do another
        >> server.transfer . This gives me the error:
        >> System.InvalidC astException: Specified cast is not[/color][/color]
        valid.[color=blue]
        >
        >It doesn't sound like a Server.Transfer problem so much[/color]
        as a type conversion[color=blue]
        >issue. By the way, I can conceive of no well-designed[/color]
        scenario where you[color=blue]
        >would actually want to do this. Server.Transfer should[/color]
        not be used to break[color=blue]
        >up code or control program flow - a terribly expensive[/color]
        way to do things. If[color=blue]
        >you need less code in your classes, then you should[/color]
        either use regions, or[color=blue]
        >abstract some of the code out to other classes.
        >
        >R/
        >
        >
        >.
        >[/color]

        Comment

        • Ignacio Machin \( .NET/ C#  MVP \)

          #5
          Re: Server.Transfer

          Hi Drew ,[color=blue]
          >
          > But you can do server.transfer to go to multiple pages?
          >
          > p1 -> -> p2 -> -> p3 -> -> p4
          >
          > doing a server.transfer on each one.[/color]

          Yes, you can, I did that yesterday testing your problem
          [color=blue]
          > Is that the proper practice for navigating web pages in c#?[/color]

          No, it's not, What are you trying to do?

          cheers,

          --
          Ignacio Machin,
          ignacio.machin AT dot.state.fl.us
          Florida Department Of Transportation


          Comment

          Working...