473,503 Members | 1,701 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Recursive WebRequest.Create()

The WebRequest class implements IWebRequestCreate and hence, a method
Create.

This method has two other overloads, one of which is a private method.
Here's how it looks:

public static WebRequest Create(string requestUriString)
public static WebRequest Create(Uri requestUri)
private static WebRequest Create(Uri requestUri, bool useUriBase)
Both the public overloads with a single argument internally call the
private overload with the second parameter as false. The implementation
of the private method is given below:
private static WebRequest Create(Uri requestUri, bool useUriBase)
{
string text1;
WebRequestPrefixElement element1 = null;
bool flag1 = false;
if (!useUriBase)
{
text1 = requestUri.AbsoluteUri;
}
else
{
text1 = requestUri.Scheme + ':';
}
int num1 = text1.Length;
ArrayList list1 = WebRequest.PrefixList;
for (int num2 = 0; num2 < list1.Count; num2++)
{
element1 = (WebRequestPrefixElement) list1[num2];
if ((num1 >= element1.Prefix.Length) &&
(string.Compare(element1.Prefix, 0, text1, 0, element1.Prefix.Length,
true, CultureInfo.InvariantCulture) == 0))
{
flag1 = true;
break;
}
}
if (!flag1)
{
throw new
NotSupportedException(SR.GetString("net_unknown_pr efix"));
}
return element1.Creator.Create(requestUri);
}
I was surprised to see the last statement of this private overload
calling one of the other public overloads. Isn't this recursive, or am
I missing something here?

May 5 '06 #1
4 1884
Hello, Sathyaish!

S> {
S> return element1.Creator.Create(requestUri);
S> }

You mean that this statement will fall in recursion?
Why do you think so?

WebRequest.Create(...), creates specific request objects. It creates them using WebRequestPrefixElement.
I do not see any recursion here....

--
Regards, Vadym Stetsyak
www: http://vadmyst.blogspot.com
May 5 '06 #2
Hi Vadym,

Thanks for replying.

I was wrong in thinking so and I realized this by writing out my
thoughts in great detail in these posts. It is a wonder that writing
your thoughts down in a detailed manner can reveal the cause of your
own confusion and give you the answer to your problem.

Here're the links for your reference:

http://discuss.joelonsoftware.com/de...et.12.339841.6

http://channel9.msdn.com/ShowPost.aspx?PostID=189550

Thanks again.

May 5 '06 #3
Hi again, Vadym!
On visiting your blog link, I recognize that I'd only followed a few
links that led to your blog only a few weeks ago. I think I know you
from elsewhere too. Do you post on JoS/CoT/Channel 9?
Regards,
Sathyaish

May 5 '06 #4
Hello, Sathyaish!

S> On visiting your blog link, I recognize that I'd only followed a few
S> links that led to your blog only a few weeks ago. I think I know you
S> from elsewhere too. Do you post on JoS/CoT/Channel 9?

Actually no. Maybe some search engines or people mentioned the link to the blog.
--
Regards, Vadym Stetsyak
www: http://vadmyst.blogspot.com
May 5 '06 #5

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

Similar topics

3
6331
by: Paul | last post by:
Hello, First I want to refer to the problem "WebRequest : execute a button" of a few days ago. The way I solved it, I loose my session, and as a consequence my session variables. I don't want...
8
2384
by: John K. | last post by:
Hi I was wondering if it's possible to use the WebRequest class to access a file on windows shared folder with authentication? If yes, what would the syntax be? I've tried to look this up in the...
4
7216
by: Terry | last post by:
Hello, I am trying to get a response for an .aspx page in my current project (same virtual directory) by using WebRequest.GetResponse but I keep getting a exception with "500 Internal server...
12
2847
by: ThyRock | last post by:
I am working on a WebRequest accessing the US Postal Service WebTools test API. This service uses a DLL file (ShippingAPITest.dll) with a query string which includes XML. The web service accepts...
0
1786
by: jesper.hvid | last post by:
Hi. I've noticed, after moving some of our code to 2.0, that System.Net.WebRequest.Create(System.String) and System.Uri(System.String) no longer behave as they did in 1.1 framework. Example:...
1
4731
by: David Satz | last post by:
Hello--I just upgraded to Visual Studio .NET 2005 and suddenly, all my .NET 1.1 applications that accessed Web sites have broken. For example, this code: WebClient wc = new WebClient();...
4
977
by: Sathyaish | last post by:
The WebRequest class implements IWebRequestCreate and hence, a method Create. This method has two other overloads, one of which is a private method. Here's how it looks: public static...
3
9557
by: eSolTec, Inc. 501(c)(3) | last post by:
Thank you in advance for any and all assistance. I'm trying to create a call to a web page to validate and register software. The code I'm using is: Private Sub OK_Click(ByVal sender As...
2
2953
by: Zytan | last post by:
I know that WebRequest.GetResponse can throw WebException from internet tutorials. However in the MSDN docs: http://msdn2.microsoft.com/en-us/library/system.net.webrequest.getresponse.aspx It...
0
7199
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
7074
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7322
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...
1
6982
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7451
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
5000
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3161
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1501
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
374
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.