473,811 Members | 3,532 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 1000
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
1911
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...
3
8189
by: Dave | last post by:
string m_request = some_web_page; HttpWebRequest request = (HttpWebRequest)WebRequest.Create(m_request ); HttpWebResponse response = (HttpWebResponse)request.GetResponse(); Which works fine, but I need to set and send a cookie with the WebRequest. How do I do that?
0
9724
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9604
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
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...
1
7665
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
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?

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.