The problem Every now and then we receive an advisory case from a customer whom needs some advices from us about how to implement some kind of functionality, and this particular one had an interesting and weird behavior with the viewstate in a custom composite control: basically the customer implemented a sort of tabbed control which had to act as a container for other controls like checkboxes, and was meant to be used at design time within Visual Studio by other developers. The control itself was actually based on a CompositeControl and a View (and MultiView) class, and everything was apparently working fine until he tried to uncheck one of the checkboxes within the control and submit the page: after the postback the checkbox was still flagged ?. The custom control was clearly the the one having the problem because another checkbox outsite it (just placed somewhere else on the page) worked as expected. It’s interesting to note that the customer has customized the viewstate management and was overriding the SaveViewState and LoadViewState events, and on my experience viewstate and the chain of events which occurs in the page lifecycle are often the ones to blame for such problems… A…
-
-
Don’t let IE local cache drive you crazy!
I stumbled across this issue multiple times during my life of web developer (which begun about 10 years ago), it appeared every now and then to complicate things when I was in the middle of a heavy debugging sessions and doing frequent changes to my pages; I was expecting some kind of results but despite the fact that the code was looking good, there were no signs of those changes. Sometimes even adding a new UI element like a button or an image or changing the color of a header had no effect… ? Having a look at the page source within IE demonstrated the browser was somehow right not showing the new image or color because it was not there in the code… where was that source coming from? ? Well, if it does not come from the web server, then it’s loaded from the IE local cache… so let’s go to Internet Options > General > Delete > Temporary Internet Files, give it another try and guess what? This time it works…! So, not sure why, but for some reason IE was not refreshing its case and was using an outdated version of my pages. Then after a…
-
Corrupt installation? Do not repair Visual Studio
(Unable to start debugging on the web server. An error occurred that usually indicates a corrupt installation. If the problem persists, repair Visual Studio installation via ‘Add or Remove Programs’ in Control Panel) I saw this happening on a Vista x64 while trying to debug an ASP.NET application and needless to say (☹️), repairing Visual Studio does not help. This is a misleading error message which might appear when you try to debug an ASP.NET application on a 64 bit OS and you configured your application pool to run a 32 bit worker process; I know it will be changed to a more meaningful message, but I’m not sure about the timeframe (I can’t repro so I’m not able to check how Visual Studio 2008 behaves). What to do then? Check the advanced settings for your application pool and set “Enable 32-bit applications” to “False” By the way, I was this error in conjunction with this one so pay attention if you’re hitting one of the two… Carlo Quote of the Day: Sincerity is the highest compliment you can pay. –Ralph Waldo Emerson
-
The error indicates that IIS is not installed on the machine. Please install IIS before using this tool
Yesterday I was working on a sample project got from a customer, when Visual Studio 2005 showed this dialog: Ok I thought, let’s fix the application mappings. I did, but got the following: What? Are you kidding me? ? Of course IIS is installed, I’m using it every day… But wait a minute, I’m running on Vista x64 and this rings a bell to me… Let’s use the x64 Visual Studio command prompt and give it another try: Much better… and now Visual Studio does not complain anymore! ? Carlo Quote of the day: We are inclined to believe those whom we do not know because they have never deceived us. – Samuel Johnson
-
Does hot deployment really means “HOT”?
Every now and then we get calls from customer having troubles with ASP.NET deployment, usually in cluster/NLB environment but sometimes also in single servers; what they usually have in common is the complexity of the web application, maybe made of dozens (if not hundreds) of pages, controls etc… Typical questions are: I am deploying my new pages and dlls but then suddenly the application is restarted, and my user lose their work and have to login again After the deployment the application is slow at startup In my NLB I randomly get inconsistent behaviors and weird exceptions we never got before We are using a tool to synchronize files and folders, and during the sync for a few seconds we receive a lot of errors telling that some dlls are not available, but after some more seconds everything is running fine again There are a few variations to the above, but you got the point. I think this might be due to a misunderstanding (of should I say the documentation is not clear enough?) about deployment capabilities of ASP.NET and what is recommended for complex/full loaded applications; the point is that ASP.NET supports hot deployment meaning that whenever you update…
-
HTTP error 406 with .NET Framework 3.0
I got a couple of cases about this problem recently… Imagine this scenario: you install the .NET Framework 3.0 on your client, and then browse an ASP.NET based web site; you get a 406 HTTP return code from the web server, which means “Client browser does not accept the MIME type of the requested page” (see IIS status codes). Uninstalling the .NET Framework 3.0 corrects the problem, and you’re finally able to successfully browse the site. The problem proved itself in two different ways and apparently for two different reasons, but the underlying cause was actually the same. The 406 return code also means that any of the configuration limits has been reached, and digging into IIS logs we found that the problem was actually due to the length of the “Accept” header which has a limit of 256 bytes. Installing the .NET Framework 3.0 you receive support for a few additional file formats, here is how it looks the Accept header on Windows Vista (where the .NET Framework 3.0 is preinstalled): Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-ms-application, application/vnd.ms-xpsdocument, application/xaml+xml, application/x-ms-xbap, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, application/x-shockwave-flash, */* In this case there was a custom ISAPI extension which was actually filtering the…
-
.NET Runtime 2.0 Error, Event id:5000
This error message was reported by a customer last week; every day, randomly, his application pools (on two servers in NLB) were restarted during business hours without an apparent reason, and of course users were complaining because of lost sessions etc…; the following entry was added to the Application event log: Event Type: Error Event Source: .NET Runtime 2.0 Error Reporting Event Category: None Event ID: 5000 Date: 9/28/2005 Time: 3:18:02 PM User: N/A Computer: IIS-SERVER Description: EventType clr20r3, P1 w3wp.exe, P2 6.0.3790.1830, P3 42435be1, P4 app_web_7437ep-9, P5 0.0.0.0, P6 433b1670, P7 9, P8 a, P9 system.exception, P10 NIL The first thing to do when we have a specific error message is to search the Knowledge Base for known issues/hotfixes etc…, and was quite easy to find the article Unhandled exceptions cause ASP.NET-based applications to unexpectedly quit in the .NET Framework 2.0 which I already used more than once in the past to resolve similar issues; I usually suggest the customer to first apply the solution described in “Method 2”: Method 2 Change the unhandled exception policy back to the default behavior that occurs in the .NET Framework 1.1 and in the .NET Framework 1.0. Note We do not recommend…
-
Is your UserControl sluggish at loading?
Here’s an interesting story about performance I had the chance to work on over the last couple of weeks. The object of the call was a UserControl embedded in Internet Explorer, which was very slow to load the first time you browsed the page, but then was performing quite well after that long delay (around 60 seconds); unfortunately closing and reopening the browser caused another 60 seconds delay, which was quite bothering if not frustrating for end users… As you can imagine the control needs to be downloaded, JIT compiled and loaded which of course requires some time depending on how big is the control, how fast (or slow) the Internet connection, how powerful the client etc…, but those 60 seconds where definitely too much. Moreover on Vista we were prompted to run csc.exe and under some circumstances (usually if IE was not run as Administrator) we got a FileNotFoundException. Probing First thing, Fiddler showed that after downloading the first dll (the actual UserControl) we were probing for further localized resources, so we wasting about 15 seconds just for this reason (which is a quarter of the entire time spent waiting on a white IE page…). At the same time…
-
Remember to undo your impersonation
A couple of weeks ago I got an interesting query from a customer, whom had a problem impersonating a service user account by code; the design was a bit more complicated, though: Impersonation not set in web.config By code they needed to impersonate the account logged on the client issuing the HTTP request (this worked fine) By code they needed to impersonate a service account they used to access a backend database (here they were getting an access denied error) Switch back to the previous user, the one logged on the client (again this was working fine) This was quite clearly an impersonation problem, and after some debugging we found the “Access Denied” was being thrown when executing the line highlighted in red in the following snippet, way before even trying to access the network to read the backend database: 1: If CType(LogonUser(username, domain, password, LOGON32_LOGON_INTERACTIVE, LOGON32_PROVIDER_DEFAULT, token), Boolean) Then 2: If DuplicateToken(token, 2, tokenDuplicate) Then 3: Dim identity As New WindowsIdentity(tokenDuplicate) 4: If System.Web.HttpContext.Current Is Nothing Then 5: Dim mImpersonatedContext As WindowsImpersonationContext = identity.Impersonate 6: Else 7: System.Web.HttpContext.Current.Items("ImpersonationContext") = identity.Impersonate 8: End If 9: End If 10: [...] In the screenshot below you can see the “Access Denied” message…
-
I have an OutOfMemory exception in my dump! Am I leaking memory?
Well… the short answer is: not necessarily ? I had this discussion a few days ago with a customer who called CSS for a crash they were having, and since he was also starting to learn some debugging and dump analysis basics, he was interested to have some deeper details about my findings in the crash dump they sent in. In particular, he thought the crash was due so an OutOfMemoryException because checking the exceptions with WinDBG, he saw something like the following: 0:000> !dumpallexceptions Going to dump the .NET Exceptions found in the heap. Number of exceptions of this type: 1 Exception 0cf500bc in MT 79b94ee4: System.ExecutionEngineException —————– Number of exceptions of this type: 1 Exception 0cf5007c in MT 79b94dac: System.StackOverflowException —————– Number of exceptions of this type: 1 Exception 0cf5003c in MT 79b94c74: System.OutOfMemoryException —————– The point is that we are pre-loading a few exception objects on the heap when starting an AppDomain, and the reason is quite simple if you think about it for a moment. Let’s pretend we don’t have exception objects preloaded: if an application ever reaches a condition where needs to allocate some more memory but there is not enough memory available, then the…