473,811 Members | 3,924 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Recursive WebRequest.Crea te()

The WebRequest class implements IWebRequestCrea te 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 requestUriStrin g)
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;
WebRequestPrefi xElement element1 = null;
bool flag1 = false;
if (!useUriBase)
{
text1 = requestUri.Abso luteUri;
}
else
{
text1 = requestUri.Sche me + ':';
}
int num1 = text1.Length;
ArrayList list1 = WebRequest.Pref ixList;
for (int num2 = 0; num2 < list1.Count; num2++)
{
element1 = (WebRequestPref ixElement) list1[num2];
if ((num1 >= element1.Prefix .Length) &&
(string.Compare (element1.Prefi x, 0, text1, 0, element1.Prefix .Length,
true, CultureInfo.Inv ariantCulture) == 0))
{
flag1 = true;
break;
}
}
if (!flag1)
{
throw new
NotSupportedExc eption(SR.GetSt ring("net_unkno wn_prefix"));
}
return element1.Creato r.Create(reques tUri);
}
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 1911
Hello, Sathyaish!

S> {
S> return element1.Creato r.Create(reques tUri);
S> }

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

WebRequest.Crea te(...), creates specific request objects. It creates them using WebRequestPrefi xElement.
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
6353
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 to keep those variables, as an alternative, as ViewState variables because I don't want to transfer to many hidden fields. This is the code I use :
8
2407
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 references available but to no avail Also, is it safer (better practise) in an LAN environment to use HTTP requests to access shared files (via ASP.NET) rather than UNC file shares TIA Regards John
4
7239
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 error" in the exception message. I am able to do this fine with another .aspx page that has no code-behind. The page that has code-behind throws the exception. What I am doing is getting the .aspx response, reading the stream, replacing
12
2871
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 the query string with no url encoding. I must pass the <> characters as they are in the query string. If these characters are url encoded the service rejects the request. This API Url is http://testing.shippingapis.com/ShippingAPITest.dll
0
1813
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: string emailHttpPath =
1
4782
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(); wc.DownloadFile("http://www.microsoft.com/", "MSFT.htm"); .... throws a WebException on the second line. The WebException doesn't specify a problem, but it has an InnerException of type NullReferenceException with the following stack trace:
4
1000
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 WebRequest Create(string requestUriString) public static WebRequest Create(Uri requestUri) private static WebRequest Create(Uri requestUri, bool useUriBase)
3
9605
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 System.Object, ByVal e As System.EventArgs) Handles OK.Click Dim WebRequest As HttpWebRequest Dim instance As HttpWebRequest =...
2
2970
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 only lists NotImplementedException in the Exceptions section. (Note that it does mention WebException in the Remarks section, but who knows if this is always the case for such classes, and thus perhaps they can't be trusted to always list these, and...
0
10644
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10394
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10127
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9201
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6882
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5552
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5690
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4336
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 we have to send another system
3
3015
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.