Best Practices for System.Net Classes what?

Discussion in 'ASP .Net' started by Janus Knudsen, Jun 26, 2004.

  1. Hello...

    Need a little explanation!

    Snippet from MSDN:
    "The following recommendations will help you use the classes contained in
    System.Net to their best advantage:

    Use WebRequest and WebResponse whenever possible instead of type casting to
    descendant classes. Applications that use WebRequest and WebResponse can
    take advantage of new Internet protocols without needing extensive code
    changes. "

    Well, it's recommended that you dont type cast to descendant classes - but
    what does that mean?

    And what classes it referring to?

    Regards
    Janus
     
    Janus Knudsen, Jun 26, 2004
    #1
    1. Advertising

  2. Janus Knudsen

    DalePres Guest

    The most common derived classes are HttpWebResponse and HttpWebRequest
    classes that are the base for the Page.Request and Page.Response objects
    that you no doubt use regularly in ASP.Net.

    Dale

    "Janus Knudsen" <> wrote in message
    news:%23%...
    > Hello...
    >
    > Need a little explanation!
    >
    > Snippet from MSDN:
    > "The following recommendations will help you use the classes contained in
    > System.Net to their best advantage:
    >
    > Use WebRequest and WebResponse whenever possible instead of type casting

    to
    > descendant classes. Applications that use WebRequest and WebResponse can
    > take advantage of new Internet protocols without needing extensive code
    > changes. "
    >
    > Well, it's recommended that you dont type cast to descendant classes - but
    > what does that mean?
    >
    > And what classes it referring to?
    >
    > Regards
    > Janus
    >
    >
     
    DalePres, Jun 26, 2004
    #2
    1. Advertising

  3. Janus Knudsen

    Joerg Jooss Guest

    DalePres wrote:
    > The most common derived classes are HttpWebResponse and HttpWebRequest
    > classes that are the base for the Page.Request and Page.Response
    > objects that you no doubt use regularly in ASP.Net.


    No, they're not. These classes are used on the client-side. Page.Request and
    Page.Response are instances of System.Web.HttpRequest and
    System.Web.HttpResponse respectively.

    Cheers,

    --
    Joerg Jooss
     
    Joerg Jooss, Jun 26, 2004
    #3
  4. Janus Knudsen

    Joerg Jooss Guest

    Janus Knudsen wrote:
    > Hello...
    >
    > Need a little explanation!
    >
    > Snippet from MSDN:
    > "The following recommendations will help you use the classes
    > contained in System.Net to their best advantage:
    >
    > Use WebRequest and WebResponse whenever possible instead of type
    > casting to descendant classes. Applications that use WebRequest and
    > WebResponse can take advantage of new Internet protocols without
    > needing extensive code changes. "
    >
    > Well, it's recommended that you dont type cast to descendant classes
    > - but what does that mean?


    It means that doing

    HttpWebRequest request
    = (HttpWebRequest) WebRequest.Create(http://localhost/page.aspx);

    is bad... which of course is utter rubbish when you really need to use
    low-level technical properties that are only exposed by HttpWebRequest.

    Cheers,

    --
    Joerg Jooss
     
    Joerg Jooss, Jun 26, 2004
    #4
  5. Janus Knudsen

    DalePres Guest

    Whoops... My mistake. Thanks

    "Joerg Jooss" <> wrote in message
    news:...
    > DalePres wrote:
    > > The most common derived classes are HttpWebResponse and HttpWebRequest
    > > classes that are the base for the Page.Request and Page.Response
    > > objects that you no doubt use regularly in ASP.Net.

    >
    > No, they're not. These classes are used on the client-side. Page.Request

    and
    > Page.Response are instances of System.Web.HttpRequest and
    > System.Web.HttpResponse respectively.
    >
    > Cheers,
    >
    > --
    > Joerg Jooss
    >
    >
     
    DalePres, Jun 26, 2004
    #5
    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. karim
    Replies:
    0
    Views:
    465
    karim
    Jul 13, 2003
  2. Craig Deelsnyder

    Best Practices - solution - namespaces - classes

    Craig Deelsnyder, Aug 3, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    431
    Vincent V
    Aug 4, 2003
  3. =?Utf-8?B?am1obWFpbmU=?=

    System.Net.WebClient Best Practices

    =?Utf-8?B?am1obWFpbmU=?=, Apr 21, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    10,288
    Steven Cheng[MSFT]
    Apr 22, 2005
  4. Miranda Evans

    best practices - how to organize classes

    Miranda Evans, Nov 25, 2003, in forum: Python
    Replies:
    1
    Views:
    346
    Roy Smith
    Nov 25, 2003
  5. Tom
    Replies:
    2
    Views:
    257
    Jorgen Grahn
    Nov 2, 2011
Loading...

Share This Page