• Uncategorized

    DropDownList with tooltip

    I recently got this question from a customer whom is binding some data to a DropDownList control inside a GridView; the various items inside the DropDownList has variable length while the control itself per their page resign requirements must be fixed, making it difficult to fully read and understand the text associated with the selected item, so the customer asked for some hints to add a tooptip functionality to the DropDownList. Before raising the call he had already searched the Internet but without much luck; I did the same myself and apparently there are plenty of samples showing how to display a tooltip when the mouse is over an item already selected in a DropDown control, but the customer wanted something different: he needed to show the tooltip over each item in the DropDownList before actually selecting them to help users make the appropriate selection. Well, for Internet Explorer 7 (al later) it is possible to use the “Title” attribute for the <option> tag: for (int i = 0; i < GridView1.Rows.Count; i++) { //Add logic to fill the GridView //Now let's iterate through the DropDown controls to add a "Title" to the //resulting HTML "<option>" elements: this will add…

  • Uncategorized

    How many application pools can you cope with?

    This is an interesting question I have to admit I had not thought to until we got a case from a customer whom was in trouble with his production servers: how many application pools can you run on IIS? Event better, how many w3wp.exe instances can the OS cope with? As quite often happens in our job, the correct answer is: it depends… First, the problem. The customer was a hosting company so they had a large numbers of sites on each web server, around 450, each of them with its own application pool, each application pool run under its own specific account and aspExecuteInMTA was set to 1 on each server. Under some circumstances asp applications from some web sites are failing with the following message (roughly translated from Spanish): Server error ‘ASP 0177 : 80070057’ Error in Server.CreateObject /site/page.asp, line 338 80070057 When the problem occurred the customer recycled the two or three top consuming web sites in terms of memory, threads and handles; then the failing web site was usually back online. Note that the failing web site was always only affected by other problematic ones, it was almost never the culprit. At first we were distracted…

  • Uncategorized

    LogParser did it again: application pool recycle

    This started as a “standard” w3wp.exe crash, but this time IIS was also randomly disabling one of the application pools on the server. This is a protection mechanism we have since IIS 6 called Rapid Fail Protection that disables ad application pool (for security and stability reasons) if it fails (encounters severe errors) too often: how often and how much time it’s configurable (see Configuring Rapid-Fail Protection in IIS 6.0), the default is 5 failures in 5 minutes. Looking at the System event log there were plenty of messages like: A worker process with process id of ‘xxx’ serving application pool ‘MyAppPool’ has requested a recycle because it reached its virtual memory limit. And also: A process serving application pool ‘MyAppPool’ exceeded time limits during shut down. The process id was ‘xxx’. How often? As usual, LogParser comes at hand. logparser "select quantize(TimeGenerated, 300) as TimeGen, count(*) as NumberOfrecycles into memory_limit_recycles.log from system.evt where EventID = 1077 and Message like '%\'MyAppPool%' group by TimeGen order by TimeGen" -i:evt -o:nat -rtp:-1 Note the “quantize” function: LogParser help states “Truncates a value to the nearest multiple of another value”; what it actually does in the command above is count the number of…

  • Uncategorized

    An interesting fusion cache lock: that’s what the GAC is meant for

    This has been an interesting case where we had an ASP.NET 2.0 application which under load was completely blocked after a few minutes. Since we were talking about a hang/deadlock (as reported from the customer), the !critlist command (you can find the command within the SieExtPub.dll extension) is a good start: 0:021> !critlist CritSec at 7a393800. Owned by thread 21. Waiting Threads: 6 7 8 9 10 11 12 13 42 72 104 107 108 109 110 111 112 113 114 115 116 CritSec at e194c. Owned by thread 32. Waiting Threads: 21 Thread 32 holds a critical section and thread 21 is waiting on it, but thread 21 is also owning another critical section, and about 20 other threads are waiting there… so apparently this is not a real deadlock (21 is waiting on 32 but 32 is not waiting on 21); but what is thread 32 doing? 0:032> kpL2000 ChildEBP RetAddr 0327fd30 7c822124 ntdll!KiFastSystemCallRet 0327fd34 77e6baa8 ntdll!NtWaitForSingleObject+0xc 0327fda4 79e718fd kernel32!WaitForSingleObjectEx+0xac 0327fde8 79e718c6 mscorwks!PEImage::LoadImage+0x199 0327fe38 79e7187c mscorwks!CLREvent::WaitEx+0x117 0327fe48 7a0e288e mscorwks!CLREvent::Wait+0x17 0327fe9c 7a086e76 mscorwks!Thread::SysSuspendForGC+0x52a 0327ff88 7a0d867b mscorwks!SVR::GCHeap::SuspendEE+0x16c 0327ffa8 7a0d8987 mscorwks!SVR::gc_heap::gc_thread_function+0x3b 0327ffb8 77e66063 mscorwks!SVR::gc_heap::gc_thread_stub+0x9b 0327ffec 00000000 kernel32!BaseThreadStart+0x34 It is waiting to start GC but it cannot, because thread 95 has PreEmptive…

  • Uncategorized

    autoConfig=”false” effects

    My post on autoConfig triggered and interesting discussion with my colleague Cenk about which is the real effect of this setting; one of his customers asked what to do if they needed to adjust only one or two values and not all the ones discussed in Contention, poor performance, and deadlocks when you make Web service requests from ASP.NET applications, they wanted to be sure they could change only what they needed to fine tune and forget about the rest. The short answer is: you can change only what you need to and leave he rest as is, since we have default values hardcoded to improve performance so you’re safe (provided the values you’re changing make sense in the context, of course). If we have a look at System.Web.Configuration.ProcessModelSection with Windbg, we can see all the properties we have in <processModel> and _defaultValue corresponds to the defaults we have in machine.config.comments: 0:000> !do 06904868 Name: System.Web.Configuration.ProcessModelSection MethodTable: 6638dcb0 EEClass: 663a0604 Size: 64(0x40) bytes (C:\Windows\assembly\GAC_32\System.Web\2.0.0.0__b03f5f7f11d50a3a\System.Web.dll) Fields: MT Field Offset Type VT Attr Value Name 7910be50 400014d 30 System.Boolean 1 instance 0 _bDataToWrite 7910be50 400014e 31 System.Boolean 1 instance 0 _bModified 7910be50 400014f 32 System.Boolean 1 instance 1 _bReadOnly 7910be50 4000150 33…

  • Uncategorized

    Ups and downs of ASP.NET Performance Counters

    Perfmon is likely the first tool you think to when it comes to monitor some internals and performance of your application and it’s relatively easy to find out information and resources on the Internet; unfortunately this seems to also be a fragile component and every now and then we receive new calls about it: event log spammed with warnings about missing or corrupted counters, values returned are inconsistent or clearly wrong etc… Messages like the following can appear after for example installing the .NET Framework 2.0 on your machine: The Open Procedure for service "ASP.NET" in DLL "C:\Windows\Microsoft.NET\Framework\v2.0.50727\aspnet_perf.dll" failed. Performance data for this service will not be available. Status code returned is data DWORD 0 To note that such warnings are logged even if your application is not running. Some troubleshooting First of all you can try to disable any third party services and processes (for example using msconfig.exe or Autoruns) and see if the problem still reproduces. If it does, you can use How to manually rebuild Performance Counter Library values to try to fix it manually, or try the following: Uninstall the  .NET Framework 2.0 If available for Perfc009.dat, Perfh009.dat and Perfh007.dat , Perfh007.dat, backup the registry keys…

  • Uncategorized

    WMI warnings 35 and 40 with ASP.NET

    Over the past couple of weeks I got to almost identical cases where the customer had the event log on their servers “spammed” by the following messages: Event Type:      Warning Event Source:   WinMgmt Event Category:           None Event ID:           40 Date:                <date> Time:                <time> User:                N/A Computer:        <computername> Description: WMI ADAP was unable to create the object Win32_PerfRawData_ASPNET_2050727_ASPNETAppsv2050727 for Performance Library ASP.NET_2.0.50727 because error 0x80041001 was returned Event Type:      Warning Event Source:   WinMgmt Event Category:           None Event ID:           35 Date:                <date> Time:                <time> User:                N/A Computer:        <computername> Description: WMI ADAP was unable to load the ASP.NET_2.0.50727 performance library because it returned invalid data: 0x0 Article How to troubleshoot WinMgmt-based performance counter errors does not help in this case (we do not have Event ID 37, 41 or 61). The fix for this problem was scheduled to be added in .NET 3.5 SP1 (as also explained in this post) then we decided to ship a standalone hotfix too: the KB article is not yet available but you can request the fix (which by the way resolved both my cases) to CSS as usual, asking for 951683.     Carlo Quote of the day: Always do right. This will gratify some people and…

  • Uncategorized

    Are you using safe Http Headers?

    There are a variety of web applications out there which are relying on http headers for different purposes: automatic redirection, streaming a binary file to the client, controlling how content is cached on the client, adapting the site’s functionalities and interface to the capabilities of the browse and a lot more I’m sure you can think to. If you’re upgrading to ASP.NET 2.0 (or higher) an existing application which relies on http headers, you might encounter some problems, especially in the case you’re producing binary context (say a PDF file) to your clients: corrupted file, or type not supported, or inability to print the downloaded document are some of the symptoms you may get. First, check your code if you have something like the following: Response.ContentType = "application/pdf"; Response.AppendHeader("Content-Disposition", "attachment; filename=document.pdf"); Response.AddHeader("Content-Length", m.GetBuffer().Length.ToString()); ObjPdf writer = ObjPdf.getInstance(document, m); document.Open(); Try changing it to this: Response.ContentType = "application/pdf"; Response.AppendHeader("Content-Disposition", "attachment; filename=document.pdf"); ObjPdf writer = ObjPdf.getInstance(document, m); document.Open(); Response.AddHeader("Content-Length", m.GetBuffer().Length.ToString()); If m.GetByffer().Length is zero then you have a problem, so it’s important to open the writer object before adding the header. useUnsafeHeaderParsing If that’s enough or you don’t want to change your code (maybe because too many pages are affected) then you…

  • Uncategorized

    “Invalid postback or callback argument” in ASP.NET

    I saw this error twice recently, but as often happens for two completely different cases so here they are, hope it helps someone to same their time… Invalid postback or callback argument. Event validation is enabled using <pages enableEventValidation="true"/> in configuration or <%@ Page EnableEventValidation="true" %> in a page. For security purposes, this feature verifies that arguments to postback or callback events originate from the server control that originally rendered them. If the data is valid and expected, use the ClientScriptManager.RegisterForEventValidation method in order to register the postback or callback data for validation Nested forms The first problematic application was dynamically building page layout and manipulating the HTML stream sent to the client; in my specific case there was some manipulation carried on the client through Javascript, but I think the same may happen if for example the HTML stream is changed through an HttpHandler after the main ASP.NET processing has been completed. The page was rendered correctly within the browser, but a postback thrown the exception above and this was due to a malformed page structure, where we had nested <form> tags like in the following example: <body> <form id="form1" runat="server"> <div> <asp:Button ID="Button1" runat="server" Text="Button" /> <form></form> </div>…