Pages

Tuesday, September 20, 2011

Methods to Redirect users to another page in ASP.Net

Using ASP.Net one can redirect to another page via the following methods:

            1. using Hyperlinks
            2. using Cross PAge Posting
            3. using Browser redirect Method
            4. using Server Transfer.

Hyperlinks:
   Charactaristics:
          - Performs new request on the target page.
          - Does not pass current page informations to the target page.
          - Requires users initiation
          - Can redirect to any page - Not just pages within application.
          - Can share information between pages using query string.
  Usage:
          - For navigation without any additional processing, as in menus or links of links.
          - When navigation should be under user control.

Cross Page Posting:
   Characteristics:
          - Post current page information to target page.
          - Makes post information available in target page.
          - Requires user initiation.
          - Can redirect to any page - Not just pages within application.
          - Enables the target page to read public properties of the source page, if the pages are in same application.
   Usage:
          - To pass current page information to target page (As in multi page forms)
          - When navigation should be under user control.

Browser Redirect:
    Characteristics:
          - Performs a new HTTP GET request on the target page.
          - Passes the query string, if any, to target page.( In IE the max size is  2048)
          - Provides programmatic and dynamic control over the target URL and query string.
          - Can redirect to any page - Not just pages within the application.
          - Can share information between source and target pages useing session state.
    Usage:
          - For conditional navigation when you want to control the target URL and control when navigation takes place.

Server Transfer:
     Characteristics:
          - Trasfers control to a new page that renders in place of the source page.
          - Redirects only to target pages taht are in the same web applciation as the source page.
          - Enables to read values and public properties from source page.
          - Doesnot update browser information with information about the target page. Pressing the refresh or back buttons in the browser can result in unexpected behaviour.
     Usage:
          - For conditional navigation, when you want to control when navigation takes place and you want access to the context of teh source page.
          - Best used when URL is hidden from the user.

No comments:

Post a Comment