Author |
Message |
Ovidiu Platon [MSFT]
|
Posted: .NET Framework Networking and Communication, WebRequest.Create in a hosted control is extremely slow |
Top |
Hello all,
Context> I'm currently working on a small web application that has a Windows Forms user control embedded in a web page. I use .NET Framework v1.1. The user control performs multiple file uploads.
Problem> I wrote the upload code using HttpWebRequest (since WebClient doesn't allow developers to use cookies). When I call WebRequest.Create(url), the first call on this method takes a large amount of time to complete (> 30s). Subsequent calls run normally, they are very fast.
Details> The user control runs with a custom set of permissions, according to its functionality, and I also tested the control in the Internet/Intranet/Trusted zones and even with Full Trust, but it behaves the same. I run everything locally (and I access the page via localhost or 127.0.0.1, depending on whether I want IE to go to the Local Intranet or Internet zone).
I also assert permissions as necessary (although discovering what permissions are needed by .NET Framework is no easy task, since many of them aren't documented - for example I discovered that Control.Invoke demands SecurityPermission for UnmanagedCode the hard way).
Does anyone have a clue what's going on
Thank you, Ovidiu
.NET Development2
|
|
|
|
|
Durgaprasad Gorti
|
Posted: .NET Framework Networking and Communication, WebRequest.Create in a hosted control is extremely slow |
Top |
We might have a hot fix for this. If you are running 1.1 SP1, then I think this issue is fixed. What version of the framework are you running
|
|
|
|
|
Ovidiu
|
Posted: .NET Framework Networking and Communication, WebRequest.Create in a hosted control is extremely slow |
Top |
Thanks for the reply. System.dll has the version number 1.0.5000.0. In Add/Remove Programs only one hotfix appears (KB 886903). I'm fairly sure that I have SP1 installed, as checking Windows Update yields no .NET Framework related updates (also, in the NGEN cache there are two copies of System.dll, an older one and a newer one).
If it helps, I can provide a CLR Profiler log file. Apparently the first call to WebRequest.Create leads to the loading of a configuration file (and in the call stack someone actually calls WebRequest.Create again). A lot of time seems to go into XML processing.
|
|
|
|
|
Durgaprasad Gorti
|
Posted: .NET Framework Networking and Communication, WebRequest.Create in a hosted control is extremely slow |
Top |
Exactly. We fixed this in 1.1 SP1. I also think we back ported to 1.0. Let me check what fix you need to install to make it work. Is there a chance you can move to 1.1 SP1
|
|
|
|
|
Ovidiu
|
Posted: .NET Framework Networking and Communication, WebRequest.Create in a hosted control is extremely slow |
Top |
As I said, it already appeared that I have 1.1 SP1 installed - when visiting Windows Update there were no .NET Framework related updates, and I have KB886903 installed, which is a post-SP1 update (http://support.microsoft.com/default.aspx scid=kb;en-us;886903).
By the way, when I said that System.dll is at version 1.0.5000.0, I meant the assembly version (and I obtained it with ildasm and by examining the GAC). The Win32 version is 1.1.4322.2032.
However, I downloaded NDP1.1sp1-KB867460-X86.exe again from http://www.microsoft.com/downloads/details.aspx FamilyID=A8F5654F-088E-40B2-BBDB-A83353618B38&displaylang=en and when I attempted to run the installer, I got the following message:
"Microsoft .NET Framework 1.1 Service Pack 1 (KB867460) is already installed. Do you want to reinstall it on Microsoft .NET Framework 1.1 " (and, for the record, I cancelled the installation; I'll run it again and let it execute completely later, maybe some miracle happens [later edit: it didn't]).
Maybe I should also mention that I searched the Microsoft Knowledge Base before posting here:
http://www.google.com/search q=WebRequest+Create+site:support.microsoft.com http://support.microsoft.com/search/default.aspx qu=WebRequest+Create
I read all results that seemed to have any connection with my problem and I failed to find an answer. I also read the lists of bugs fixed in 1.1 SP1 (at http://support.microsoft.com/default.aspx scid=kb;en-us;867460 and http://support.microsoft.com/default.aspx scid=kb;en-us;888528) and I still don't have a clue about what's going on.
Thank you for your time, Ovidiu
|
|
|
|
|
Durgaprasad Gorti
|
Posted: .NET Framework Networking and Communication, WebRequest.Create in a hosted control is extremely slow |
Top |
as a workaround, can you create a socket first [no need to use it - just create a socket] and then create the webrequest.create I am curious if the problem goes away
|
|
|
|
|
Ovidiu
|
Posted: .NET Framework Networking and Communication, WebRequest.Create in a hosted control is extremely slow |
Top |
This is interesting. The problem didn't go away, but it moved to Socket(). My suspicious line of code is:
| | HttpWebRequest fileUploadRequest = (HttpWebRequest)WebRequest.Create(address); |
(Where "address" is of type System.Uri and always points to a HTTP URL). Right before this line, I inserted:
| | Socket s = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); |
Now the call to the Socket constructor is the one blocking for many seconds. I played around with CLR Profiler and I have a new trace for this situation. Essentially, the ****point is ConfigurationSettings.GetConfig in both scenarios.
Later edit: Since ConfigurationSettings.GetConfig seems to be at fault, I searched the web and the knowledge base for known issues about networking functions in hosted controls, correlated with GetConfig. Indeed, the problem is well known and appears in various scenarios (remoting, sockets, DNS lookups and so on). I found many comments on the issue:
http://www.hide-link.com/ http://www.hide-link.com/ http://www.hide-link.com/ ;q=ConfigurationSettings+GetConfig+internet+explorer+host+OR+hosted&rnum=3#ed7ac58dff264395 http://www.hide-link.com/ ;q=ConfigurationSettings+GetConfig+internet+explorer+host+OR+hosted&rnum=5#8e3cc1ddb60587b5
The suggested remedy is to call ConfigurationSettings.GetConfig(argument), where argument can be "DNS", "foo", "some string", "system.net/settings" or some other value. Unfortunately none of these workarounds does the trick for me. This simply moves the place where the bug manifests itself, but it doesn't seem to eliminate the consequence (the 60 - 100 second delay). If I put GetConfig in the constructor of the control, the user will have to wait for a minute before the page will be fully loaded. If I put it in a background thread, the control will load, but it will still be unusable until the GetConfig call releases all locks. Still digging into the issue.
|
|
|
|
|
Durgaprasad Gorti
|
Posted: .NET Framework Networking and Communication, WebRequest.Create in a hosted control is extremely slow |
Top |
This issue is fixed. Let me search the exact patch number or QFE and will get back to you. Sorry for the inconvinience
|
|
|
|
|
Durgaprasad Gorti
|
Posted: .NET Framework Networking and Communication, WebRequest.Create in a hosted control is extremely slow |
Top |
This issue is fixed post 1.1 SP1. This will be included in 1.1 SP2. You might need to call product support and ask for this patch. Let me also follow up and see what I can do..
|
|
|
|
|
Ovidiu
|
Posted: .NET Framework Networking and Communication, WebRequest.Create in a hosted control is extremely slow |
Top |
Thank you very much for your support. I sincerely appreciate the time you've taken to answer my questions.
|
|
|
|
|
Durgaprasad Gorti
|
Posted: .NET Framework Networking and Communication, WebRequest.Create in a hosted control is extremely slow |
Top |
Ovidu, I need to know the following.
OS: Language: The exact version of the system.dll on your machine
Then I can send you the fix. You can email me directly this information at
[remove the dontspam]
I can then send you the fix for this issue. Thanks
|
|
|
|
|
SWGA Architect
|
Posted: .NET Framework Networking and Communication, WebRequest.Create in a hosted control is extremely slow |
Top |
Did you ever resolve this problem I am experiencing the same behavior with a very similar implementation.
|
|
|
|
|
Durgaprasad Gorti
|
Posted: .NET Framework Networking and Communication, WebRequest.Create in a hosted control is extremely slow |
Top |
Apparently it is. I sent you the hotfix.
|
|
|
|
|
John Landreth
|
Posted: .NET Framework Networking and Communication, WebRequest.Create in a hosted control is extremely slow |
Top |
I am experiencing this same problem with .NET 2.0. What was the hot fix and will it work with .NET 2.0
Thanks in advance.
|
|
|
|
|
alanuiuc20
|
Posted: .NET Framework Networking and Communication, WebRequest.Create in a hosted control is extremely slow |
Top |
I also have the same problem. I have .NET 2.0 installed as well as the 1.1 Hotfix. I'm running SP2 and the Windows Update tells me there are no updates necessary for my machine.
Is there a hotfix for this specific issue, available for download somewhere
Thanks
Alan
|
|
|
|
|
|