Response.Redirect not being called after sending an email

Discussion in 'ASP .Net Web Controls' started by Nathan Sokalski, Jun 24, 2006.

  1. The last two lines of code in the Click event of a Button Control on my page
    are:


    Me.WelcomeEmail()
    Response.Redirect("mainmenu.aspx")


    The last line of code in Me.WelcomeEmail() is:


    Mail.SmtpMail.Send(mailmsg)


    When the Click event is triggered, all of the code in Me.WelcomeEmail() is
    successfully executed, and the email is successfully sent, but the
    Response.Redirect("mainmenu.aspx") line is not executed, and a blank page is
    displayed with the URL of the page that this code is run from. However, if I
    use Server.Transfer instead as follows:


    Me.WelcomeEmail()
    Server.Transfer("mainmenu.aspx")
    Response.Redirect("mainmenu.aspx") 'This line obviously won't get executed
    here because Server.Transfer is executed first


    The Server.Transfer line does get executed, and I see the page
    mainmenu.aspx. However, I do not want this because I want the displayed URL
    to match the displayed page, which is not true when using Server.Transfer.
    Why is Response.Redirect not working here, and what can I do to fix it?
    Thanks.
    --
    Nathan Sokalski

    http://www.nathansokalski.com/
    Nathan Sokalski, Jun 24, 2006
    #1
    1. Advertising

  2. Nathan Sokalski

    vMike Guest

    "Nathan Sokalski" <> wrote in message
    news:...
    > The last two lines of code in the Click event of a Button Control on my
    > page are:
    >
    >
    > Me.WelcomeEmail()
    > Response.Redirect("mainmenu.aspx")
    >
    >
    > The last line of code in Me.WelcomeEmail() is:
    >
    >
    > Mail.SmtpMail.Send(mailmsg)
    >
    >
    > When the Click event is triggered, all of the code in Me.WelcomeEmail() is
    > successfully executed, and the email is successfully sent, but the
    > Response.Redirect("mainmenu.aspx") line is not executed, and a blank page
    > is displayed with the URL of the page that this code is run from. However,
    > if I use Server.Transfer instead as follows:
    >
    >
    > Me.WelcomeEmail()
    > Server.Transfer("mainmenu.aspx")
    > Response.Redirect("mainmenu.aspx") 'This line obviously won't get executed
    > here because Server.Transfer is executed first
    >
    >
    > The Server.Transfer line does get executed, and I see the page
    > mainmenu.aspx. However, I do not want this because I want the displayed
    > URL to match the displayed page, which is not true when using
    > Server.Transfer. Why is Response.Redirect not working here, and what can I
    > do to fix it? Thanks.
    > --
    > Nathan Sokalski
    >
    > http://www.nathansokalski.com/

    Sounds like you have an incomplete path to the page.
    vMike, Jun 24, 2006
    #2
    1. Advertising

  3. I doubt that is the problem, for several reasons.

    1. mainmenu.aspx is in the same directory as the page that this code is in,
    so I shouldn't need anything other than the filename, right?
    2. If that was the problem, wouldn't it give me an error saying it could not
    find mainmenu.aspx?
    3. Why is Server.Transfer working when I do not pass it anything other than
    the filename?
    4. I tried using the complete URL (http://www.mydomain.org/mainmenu.aspx),
    but it did not make any difference.

    However, I think that I did find the reason, but I think it will require a
    compromise. When I do a view source on the blank page that shows up when it
    should be redirected to mainmenu.aspx, I see two body tags and a set of tags
    that I think come from ASP.NET's SmartNav feature. One of the attributes in
    this tag is the URL that it should be redirected to. I think that the
    SmartNav feature is what is causing the problem, so I guess I'll have to do
    without it for now.
    --
    Nathan Sokalski

    http://www.nathansokalski.com/

    "vMike" <> wrote in message
    news:7dang.6107$...
    >
    > "Nathan Sokalski" <> wrote in message
    > news:...
    >> The last two lines of code in the Click event of a Button Control on my
    >> page are:
    >>
    >>
    >> Me.WelcomeEmail()
    >> Response.Redirect("mainmenu.aspx")
    >>
    >>
    >> The last line of code in Me.WelcomeEmail() is:
    >>
    >>
    >> Mail.SmtpMail.Send(mailmsg)
    >>
    >>
    >> When the Click event is triggered, all of the code in Me.WelcomeEmail()
    >> is successfully executed, and the email is successfully sent, but the
    >> Response.Redirect("mainmenu.aspx") line is not executed, and a blank page
    >> is displayed with the URL of the page that this code is run from.
    >> However, if I use Server.Transfer instead as follows:
    >>
    >>
    >> Me.WelcomeEmail()
    >> Server.Transfer("mainmenu.aspx")
    >> Response.Redirect("mainmenu.aspx") 'This line obviously won't get
    >> executed here because Server.Transfer is executed first
    >>
    >>
    >> The Server.Transfer line does get executed, and I see the page
    >> mainmenu.aspx. However, I do not want this because I want the displayed
    >> URL to match the displayed page, which is not true when using
    >> Server.Transfer. Why is Response.Redirect not working here, and what can
    >> I do to fix it? Thanks.
    >> --
    >> Nathan Sokalski
    >>
    >> http://www.nathansokalski.com/

    > Sounds like you have an incomplete path to the page.
    >
    Nathan Sokalski, Jun 24, 2006
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Glen Wilkin via DotNetMonster.com

    Response.Redirect after Response.Flush

    Glen Wilkin via DotNetMonster.com, Apr 15, 2005, in forum: ASP .Net
    Replies:
    2
    Views:
    6,931
  2. Nathan Sokalski
    Replies:
    2
    Views:
    350
    Nathan Sokalski
    Jun 24, 2006
  3. Replies:
    5
    Views:
    567
    =?ISO-8859-1?Q?G=F6ran_Andersson?=
    Jun 12, 2007
  4. Sal
    Replies:
    1
    Views:
    406
  5. Felix
    Replies:
    1
    Views:
    337
    Felix
    Sep 29, 2006
Loading...

Share This Page