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. server.transfer vs response.redirect

server.transfer vs response.redirect

Scheduled Pinned Locked Moved ASP.NET
visual-studiosysadmin
4 Posts 4 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.
  • L Offline
    L Offline
    lavanya_satheesh
    wrote on last edited by
    #1

    Please tell me the exact difference between server.transfer and response.redirect.

    _ T V 3 Replies Last reply
    0
    • L lavanya_satheesh

      Please tell me the exact difference between server.transfer and response.redirect.

      _ Offline
      _ Offline
      _AK_
      wrote on last edited by
      #2

      http://www.google.co.in/search?hl=en&q=server.transfer+response.redirect+&btnG=Google+Search&meta= Best Regards, Apurva Kaushal

      1 Reply Last reply
      0
      • L lavanya_satheesh

        Please tell me the exact difference between server.transfer and response.redirect.

        T Offline
        T Offline
        Tirthadip
        wrote on last edited by
        #3

        hi, it will help you http://www.developer.com/net/asp/article.php/3299641[^] Tirtha Live life to the fullest

        1 Reply Last reply
        0
        • L lavanya_satheesh

          Please tell me the exact difference between server.transfer and response.redirect.

          V Offline
          V Offline
          Vipin Venugopal
          wrote on last edited by
          #4

          Using Querystring Querystring is a day old mechanism to pass values across pages. The main advantage of this method is it is very simple. However, disadvantages are the values are visible in the browser address bar and you can not pass objects this way. This method is best suited when you want to pass small number of values that need not be secured from others. In order to implement this method you will follow these steps: § Create the web form with controls § Provide some button or link button that posts the form back § In the click event of the button create a string that holds URL for another § Add control values to this URL as querystring parameters § Response.Redirect to another form with this URL Following code snippet shows how it works: Source Web Form private void Button1_Click (object sender, System.EventArgs e) { string url; url="anotherwebform.aspx?name=" + TextBox1.Text + "&email=" + TextBox2.Text; Response.Redirect(url); } Destination Web Form private void Page_Load (object sender, System.EventArgs e) { Label1.Text=Request.QueryString["name"]; Label2.Text=Request.QueryString["email"]; } Server.Transfer This is yet another way to pass values across pages. Here you store control values in session variables and access them in another web form. However, as you know storing too much data in session can be an overhead on the server. So, you should use this method with care. Also, it requires some kind of clean up action from your side so that unwanted session variables are removed. The typical sequence of steps will be as follows: § Create the web form with controls § Provide some button or link button that posts the form back § In the click event of the button add session variables and set them to control values § Response.Redirect to another form § In that form access Session variables and remove them if necessary Following code shows this in action: Source Web Form private void Button1_Click (object sender, System.EventArgs e) { //textbox1 and textbox2 are webform //controls Session["name"]=TextBox1.Text; Session["email"]=TextBox2.Text; Server.Transfer("anotherwebform.aspx"); } Destination Web Form private void Page_Load (object sender, System.EventArgs e) { Label1.Text=Session["name"].ToString(); Label2.Text=Session["email"].ToString(); Session.Remove("name"); Session.Remove("email"); }

          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