Context or URL ?

Discussion in 'ASP .Net' started by Steph, Mar 13, 2005.

  1. Steph

    Steph Guest

    Hi,

    Is it better to use the URL method to send informations to a page, or to use
    the context method ?

    Thanks.
     
    Steph, Mar 13, 2005
    #1
    1. Advertising

  2. Steph

    WJ Guest

    If the caller is of "Page" class, then Response.Redirect("url.aspx",..)
    would be more than enough. If the caller is not of class "Page", then you
    have to use HttpContext.

    John

    "Steph" <no_spam@no_spam.org> wrote in message
    news:uNELXk%...
    > Hi,
    >
    > Is it better to use the URL method to send informations to a page, or to
    > use
    > the context method ?
    >
    > Thanks.
    >
    >
     
    WJ, Mar 13, 2005
    #2
    1. Advertising

  3. Steph

    Karl Seguin Guest

    I don't understand this question. You'd use the QueryString (what I think
    you mean by "URL Method") and the HttpContext for very different
    situations. Accross requests you can't use HttpContext, within a request
    you can't use Querystring....

    Perhaps this article would help:
    http://openmymind.net/index.aspx?documentId=6

    Karl

    --
    MY ASP.Net tutorials
    http://www.openmymind.net/ - New and Improved (yes, the popup is annoying)
    http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
    come!)


    "Steph" <no_spam@no_spam.org> wrote in message
    news:uNELXk%...
    > Hi,
    >
    > Is it better to use the URL method to send informations to a page, or to

    use
    > the context method ?
    >
    > Thanks.
    >
    >
     
    Karl Seguin, Mar 13, 2005
    #3
  4. Steph

    Steph Guest

    Ok, my question was not so clear...
    I have page1 and page2
    Is it better to use in page2:
    A/ Request.Querystring
    B/ page1 mypage = (page1)Context.handler
    label1.text = page1.Name
    (In page1 i have a Name property with a get (readonly)...)

    Thanks.
     
    Steph, Mar 14, 2005
    #4
  5. Steph

    Karl Seguin Guest

    Steph:

    You can't have Page1 and Page2 loaded at the same time

    where are these being used? where are you doing (page1)Context.handler
    from? From a user control? Some class?

    Karl

    --
    MY ASP.Net tutorials
    http://www.openmymind.net/ - New and Improved (yes, the popup is annoying)
    http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
    come!)


    "Steph" <no_spam@no_spam.org> wrote in message
    news:...
    > Ok, my question was not so clear...
    > I have page1 and page2
    > Is it better to use in page2:
    > A/ Request.Querystring
    > B/ page1 mypage = (page1)Context.handler
    > label1.text = page1.Name
    > (In page1 i have a Name property with a get (readonly)...)
    >
    > Thanks.
    >
    >
    >
     
    Karl Seguin, Mar 14, 2005
    #5
  6. Steph

    Steph Guest

    Ok, let's try something different...

    I have a submit form on page1 and want to reach page2 and retreive the
    values.
    To do this, i have several methods (cache, shared variable, session
    variable...) but i am focused on these:

    * page1: on the button1 clic method for ex, i have
    Response.Redirect["page2.aspx?id=45"] and on page2 i have label1.text =
    Request.Querystring["id"]

    * page1 : i create a property (id for ex...) with a get (do not need a set
    of course...) and on the button1 clic method i have a
    Server.Transfer("page2.aspx")
    And on page2 i have:
    page1 mypage = (page1)Context.handler
    label1.text = page1.id

    These two solutions both works. But i need to know if there is one better
    than the other...

    Is it more clear ?!

    Thanks for taking time.
     
    Steph, Mar 14, 2005
    #6
  7. Steph

    Karl Seguin Guest

    It's crystal clear :) Sorry, but without context it's difficult to
    understand...

    Each method has advantages and disadvantages:

    Method 1 can be bookmarked, but it has ugly paths and puts an extra hit on
    the client/server

    Method 2 can't be bookmarked, but it's much prettier and more efficient

    If you don't need to bookmark, I'd go with method 2.

    I'd also improve it...instead of using Context.Handler, I'd store the values
    in Context.Items and then retrieve them from Context.Items. Using
    (page1)Context.Handler effectively binds Page2 to Page1 which should be
    avoided if possible (which you can via Context.Items)

    Karl

    --
    MY ASP.Net tutorials
    http://www.openmymind.net/ - New and Improved (yes, the popup is annoying)
    http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
    come!)


    "Steph" <no_spam@no_spam.org> wrote in message
    news:...
    > Ok, let's try something different...
    >
    > I have a submit form on page1 and want to reach page2 and retreive the
    > values.
    > To do this, i have several methods (cache, shared variable, session
    > variable...) but i am focused on these:
    >
    > * page1: on the button1 clic method for ex, i have
    > Response.Redirect["page2.aspx?id=45"] and on page2 i have label1.text =
    > Request.Querystring["id"]
    >
    > * page1 : i create a property (id for ex...) with a get (do not need a set
    > of course...) and on the button1 clic method i have a
    > Server.Transfer("page2.aspx")
    > And on page2 i have:
    > page1 mypage = (page1)Context.handler
    > label1.text = page1.id
    >
    > These two solutions both works. But i need to know if there is one better
    > than the other...
    >
    > Is it more clear ?!
    >
    > Thanks for taking time.
    >
    >
     
    Karl Seguin, Mar 14, 2005
    #7
  8. Steph

    Steph Guest

    Ok, that's it !!
    Thanks for answering.

    But if you use Context.items, it's pretty like using Session variables no ?
    And then, this may take a large amount of server memory, don't you think ?
     
    Steph, Mar 15, 2005
    #8
  9. Steph

    Karl Seguin Guest

    Context.Item IS stored in memory, but only for the lifetime of a single
    request...unlike session variables which are stored for the lifetime of a
    user visit...as such they do share similarities, but I doubt you'll run into
    any problems.

    Karl

    --
    MY ASP.Net tutorials
    http://www.openmymind.net/ - New and Improved (yes, the popup is annoying)
    http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
    come!)


    "Steph" <no_spam@no_spam.org> wrote in message
    news:...
    > Ok, that's it !!
    > Thanks for answering.
    >
    > But if you use Context.items, it's pretty like using Session variables no

    ?
    > And then, this may take a large amount of server memory, don't you think ?
    >
    >
     
    Karl Seguin, Mar 15, 2005
    #9
    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. VS_NET_DEV
    Replies:
    2
    Views:
    3,815
    jenny
    May 25, 2004
  2. =?Utf-8?B?U3VuU21pbGU=?=
    Replies:
    0
    Views:
    711
    =?Utf-8?B?U3VuU21pbGU=?=
    Jan 10, 2006
  3. Flip Rayner
    Replies:
    1
    Views:
    683
    bruce barker
    Jan 23, 2007
  4. asd
    Replies:
    1
    Views:
    445
    www.pulpjava.com
    Nov 9, 2006
  5. Jani Tiainen
    Replies:
    3
    Views:
    1,035
    Jani Tiainen
    Aug 27, 2007
Loading...

Share This Page