473,386 Members | 1,795 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Best Practices for System.Net Classes what?

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
Nov 18 '05 #1
4 1006
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" <bs@sol.dk> wrote in message
news:%2*****************@TK2MSFTNGP12.phx.gbl...
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

Nov 18 '05 #2
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
jo*********@gmx.net

Nov 18 '05 #3
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
jo*********@gmx.net

Nov 18 '05 #4
Whoops... My mistake. Thanks

"Joerg Jooss" <jo*********@gmx.net> wrote in message
news:OV**************@TK2MSFTNGP09.phx.gbl...
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
jo*********@gmx.net

Nov 18 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

16
by: D Witherspoon | last post by:
I am developing a Windows Forms application in VB.NET that will use .NET remoting to access the data tier classes. A very simple way I have come up with is by creating typed (.xsd) datasets. For...
11
by: DrUg13 | last post by:
In java, this seems so easy. You need a new object Object test = new Object() gives me exactly what I want. could someone please help me understand the different ways to do the same thing in...
136
by: Matt Kruse | last post by:
http://www.JavascriptToolbox.com/bestpractices/ I started writing this up as a guide for some people who were looking for general tips on how to do things the 'right way' with Javascript. Their...
14
by: 42 | last post by:
Hi, Stupid question: I keep bumping into the desire to create classes and properties with the same name and the current favored naming conventions aren't automatically differentiating them......
3
by: xzzy | last post by:
I was wondering why we have to have using System.Data using System.Configuration using etc.... why are they not all lumped into one 'using'? In other words, is there a best way to use...
10
by: jojobar | last post by:
Hello, I am trying to use vs.net 2005 to migrate a project originally in vs.net 2003. I started with creation of a "web site", and then created folders for each component of the site. I read...
3
by: Jeff S | last post by:
Just wondering if it's standard practice to make DAL classes STATIC (in a Windows Forms). Doing so would make sense to me because DAL methods are typically called quite frequently - certainly the...
1
by: D Witherspoon | last post by:
Coming up with a scenario here. For example there is the standard .NET MailMessage class. I am creating a project (let's call it CommonBase) that has the following 2 classes ...
41
by: Jim | last post by:
Hi guys, I have an object which represents an "item" in a CMS "component" where an "item" in the most basic form just a field, and a "component" is effectively a table. "item" objects can be...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.