Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Do I need to call return statement after a Response.Redirect method ?

Do I need to call return statement after a Response.Redirect method ?

Scheduled Pinned Locked Moved ASP.NET
questioncsharpasp-netdatabase
6 Posts 5 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    Nadia Monalisa
    wrote on last edited by
    #1

    Hi, In my asp.net web form's page_load event, I want to check if the query string 'id' is there or not. If not, then transfer the user to another page. Now, I am using this code.

    protected void Page_Load(object sender, EventArgs e)
    {
    if (Request.QueryString["id"] == null)
    {
    Response.Redirect(ResolveUrl("~/Projects"));
    return;
    }

            int x = 5;
            int y = 4;
            doSomething(x,y); 
      }
    

    Now, my question is, DO I NEED TO CALL THE 'return' STATEMENT after Response.Redirect(ResolveUrl("~/Projects")); call ? Wont the page automatically die after this Redirect method call ? Thanks.

    P M N S 4 Replies Last reply
    0
    • N Nadia Monalisa

      Hi, In my asp.net web form's page_load event, I want to check if the query string 'id' is there or not. If not, then transfer the user to another page. Now, I am using this code.

      protected void Page_Load(object sender, EventArgs e)
      {
      if (Request.QueryString["id"] == null)
      {
      Response.Redirect(ResolveUrl("~/Projects"));
      return;
      }

              int x = 5;
              int y = 4;
              doSomething(x,y); 
        }
      

      Now, my question is, DO I NEED TO CALL THE 'return' STATEMENT after Response.Redirect(ResolveUrl("~/Projects")); call ? Wont the page automatically die after this Redirect method call ? Thanks.

      P Offline
      P Offline
      padmanabhan N
      wrote on last edited by
      #2

      I am not sure,but there is no need of return statement after the response.redirect();

      Padmanabhan My Articles: Articles[^] My latest Article: Word Automation[^]

      1 Reply Last reply
      0
      • N Nadia Monalisa

        Hi, In my asp.net web form's page_load event, I want to check if the query string 'id' is there or not. If not, then transfer the user to another page. Now, I am using this code.

        protected void Page_Load(object sender, EventArgs e)
        {
        if (Request.QueryString["id"] == null)
        {
        Response.Redirect(ResolveUrl("~/Projects"));
        return;
        }

                int x = 5;
                int y = 4;
                doSomething(x,y); 
          }
        

        Now, my question is, DO I NEED TO CALL THE 'return' STATEMENT after Response.Redirect(ResolveUrl("~/Projects")); call ? Wont the page automatically die after this Redirect method call ? Thanks.

        M Offline
        M Offline
        m dhu
        wrote on last edited by
        #3

        i dont think so any statemnt will be executed after page is redirected.....

        1 Reply Last reply
        0
        • N Nadia Monalisa

          Hi, In my asp.net web form's page_load event, I want to check if the query string 'id' is there or not. If not, then transfer the user to another page. Now, I am using this code.

          protected void Page_Load(object sender, EventArgs e)
          {
          if (Request.QueryString["id"] == null)
          {
          Response.Redirect(ResolveUrl("~/Projects"));
          return;
          }

                  int x = 5;
                  int y = 4;
                  doSomething(x,y); 
            }
          

          Now, my question is, DO I NEED TO CALL THE 'return' STATEMENT after Response.Redirect(ResolveUrl("~/Projects")); call ? Wont the page automatically die after this Redirect method call ? Thanks.

          N Offline
          N Offline
          Nishant Singh
          wrote on last edited by
          #4

          If You want to be Dobly Sure use this

          Response.Redirect(ResolveUrl("~/Projects"),true);

          This will end the excecution of Current page ..... No Need of using Return

          1 Reply Last reply
          0
          • N Nadia Monalisa

            Hi, In my asp.net web form's page_load event, I want to check if the query string 'id' is there or not. If not, then transfer the user to another page. Now, I am using this code.

            protected void Page_Load(object sender, EventArgs e)
            {
            if (Request.QueryString["id"] == null)
            {
            Response.Redirect(ResolveUrl("~/Projects"));
            return;
            }

                    int x = 5;
                    int y = 4;
                    doSomething(x,y); 
              }
            

            Now, my question is, DO I NEED TO CALL THE 'return' STATEMENT after Response.Redirect(ResolveUrl("~/Projects")); call ? Wont the page automatically die after this Redirect method call ? Thanks.

            S Offline
            S Offline
            sandamalsilva
            wrote on last edited by
            #5

            Is that the problem that you are afraid that below code will execute after Response.Redirect executes, isnt it? so dont be afraid. if the program reaches that Response.Redirect line, it normally stop executing that process and pass the control to next process, it will never execute below coding int x = 5; int y = 4; doSomething(x,y);

            N 1 Reply Last reply
            0
            • S sandamalsilva

              Is that the problem that you are afraid that below code will execute after Response.Redirect executes, isnt it? so dont be afraid. if the program reaches that Response.Redirect line, it normally stop executing that process and pass the control to next process, it will never execute below coding int x = 5; int y = 4; doSomething(x,y);

              N Offline
              N Offline
              Nadia Monalisa
              wrote on last edited by
              #6

              Thanks San for your helpful answer.

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups