In ASP.NET 2.0 we have a new powerful monitoring feature called “Web Events” which help keep track of important events happening during your application’s lifetime, such as the application is starting, is stopping, it has been recompiled, exceptions etc… Web events are consumed by providers (listeners), which read the information packaged with the event and then record the information. Each provider is written to record the Web event data in a different way. For example, one provider might write to the Windows event log, while another might send an e-mail message. We have several built-in Web Events and 3 Providers available, and of course you can build your own using the classes provided in the System.Web.Management namespace; however there are only two events enabled in the rules element: All Errors and Failure Audits. Both are enabled and are subscribed to by the EventLogProvider. In it’s simplest form, for example, you can tell ASP.NET to make an event log entry each time an application starts or shuts down by adding this to the <system.web> section of the web.config file for the application: <healthMonitoring enabled="true" heartbeatInterval="0"> <rules> <add name="Lifetime event logging rule" eventName="Application Lifetime Events" provider="EventLogProvider" /> </rules> </healthMonitoring> The sample code…
-
-
ASP.NET incorrectly raises a CheckChanged event for a read only checkbox
Here’s another interesting one: we had a .aspx page with some controls on it, and one of those controls were a CheckBox; upon a postback, we were trying to set the CheckBox as readonly. What we obtained is that ASP.NET incorrectly raised a CheckChange event even though none clicked on the CheckBox and so that event was not expected to fire; it seems as if the viewstate handler incorrectly detects a change to the checked value. First of all, Internet Explorer does not include the value of disabled controls in a postback to the server; secondly, an unchecked checkbox is not included in the post back either. So the way ASP.NET detects if a CheckBox has been unchecked, is assume that if checkbox is missing in the postback then it is unchecked, otherwise checked. It also turned out that the customer was overriding the RenderChildren method for his purposes, and in that method he disabled some of the controls sent to IE after the controls have any chance to store their new state in view state. Then keeping the browser’s behavior in mind, ASP.NET believes the CheckBox was unchecked, and fired the onCheckedChange event. In summary, upon a post back here, roughly…
-
Unable to attach to process (on localhost)
Another interesting one I got a few days ago: after installing the SP1 for Visual Studio 2003, the customer was unable to debug his web application (on localhost) neither pressing F5 nor attaching to the target w3wp.exe process. As you can imagine, removing SP1 the problem disappeared. Moreover they had multiple machines running the same OS and software that worked fine, only one particular machine was affected by this problem; more interestingly, other developers were able to remotely debug their application hosted on the affected server, so only debugging on localhost was not working (WinForm debugging was also working fine). Of course the account used to login on the server was a local administrator. The target platform we were running on was Windows Server 2003 R2 x64 on AMD Operton 280 (dual core, 2.4GHz) with 4GB RAM; IIS is configured to run in 32 bit mode (w3svc/AppPools/Enable32bitAppOnWin64 = TRUE), and of course Visual Studio .NET 2003 with Service Pack 1. To start troubleshooting this I did a quick research in our internal docs and it turner out that his is a known issue due to loopback check; basically the reason is because the underlying DEBUG request is getting a 401 response, causing the…
-
Deploy CAS new code groups
Yesterday I got a call from a customer who needed some help configuring CAS settings for his application, and after finding the right one for his needs, he asked me how to easily configure all of their few thousands clients with the new settings. Well… a quick research brought up the following article: “HOW TO: Build and Deploy a .NET Security Policy Deployment Package“; but the customer wanted to deploy only the new code group we created for the application, and not his entire “Machine” policy… the CAS administration console allows you to create a .msi deployment package for the entire Enterprise, Machine or User, but unfortunately not for a single Code Group. The easiest way we found was to run the following command on the clients (through some automation mechanism the customer will identify depending on his needs):caspol -machine -addgroup All_Code -site localhost FullTrust -name “code group name“ The above command will create a new code group at machine level, as child of the group “All_Code”, will use the “Site” membership condition and will set it to “localhost” granting “FullTrust”, and the new code group will be assigned whatever name you’ll set as the “–name” argument (this must be enclosed…
-
Connected again… finally!
After about 40 days of argues, debates, emails, calls etc… well… finally our beloved Telecom company found some time to give me a phone line and the long awaited broadband Internet connection! ⏱
-
WebClient 2.0 class not working under Win2000 with HTTPS
Here is another problem I had a couple of days ago: the customer had a critical problem with on one of his .NET applications: he has migrated it to the .NET Framework 2.0, but it doesn’t work anymore under Windows 2000. They have isolated the problem and here is the source code to reproduce the problem: using System; using System.Text; using System.Net; namespace ConsoleApplication { class Program { static void Main(string[] args) { try { string url = "https://myprotectedsite.com"; WebClient client = new WebClient(); byte[] result = client.DownloadData(url); Console.WriteLine("result len=" + result.Length); } catch (Exception ex) { Console.WriteLine("EXCEPTION: " + ex); } Console.Write("Type enter to exit"); Console.ReadLine(); } } } The code above works properly on Windows XP and Windows 2003, and it displays “result len=582” (or wathever the lenght of the retrieved http stream is). It works also on Windows 2000 if you compile it with Visual Studio 2003 (i.e. .NET Framework 1.1); however if you compile it with Visual Studio 2005, it doesn’t work under Windows 2000. This is the exception we got: System.Net.WebException: The underlying connection was closed: Could not establish secure channel for SSL/TLSat System.Net.WebClient.DownloadDataInternal(Uri address, WebRequest request)at System.Net.WebClient.DownloadData(Uri address)at System.Net.WebClient.DownloadData(String address)at ConsoleApplication.Program.Main(String[] args) I first thought…
-
ASP.NET 2.0 posts back to ASP.NET 1.1: supported?
Last week I got an interesting question from a customer, apparently easy but something I really had never thought before… They have some ASP.NET 1.1 applications running in their environment, while the new apps they are currently developing, are based on ASP.NET 2.0: from one of those new pages they need to post some form values to an ASP.NET 1.1 page (both running on the same Win2003 server but in different application pools, to avoid the limitation of having just one CLR version per process); they use cross-page postback through the PostBackPage property for the submit button to target the 1.1 page, but this throws an InvalidCastException on LoadPageViewState() (which I guess is expected since 1.1 and 2.0 Viewstates are encoded differently). Question: is this scenario supported at all? How could this work? Well… it turns out that the ASP.NET 1.1 and 2.0 viewstate are encoded differently and are not compatible; moreover even if you set EnableViewState=”false” at page level this does not completely turns viewstate off, so every time you’ll execute the page you’ll get the InvalidCastException as before. Based on customer’s requirements, we identified the following possible solutions: POST from a classic ASP or HTML page: of course, since…
-
Enable System Restore on Windows 2003
Have you ever found yourself in a situation where after installing some particularly appealing application, a new video driver which promises astonishing effects with your new PC game, and after a reboot the system simply refuses to start? Or maybe you enter your credentials as you already did probably a million times, and you then end up watching a box which tells “Applying computer settings” but this lasts forever? Being quite curious towards technology and technical gadgets (not necessarily meaning Vista gadgets 😊), and due to may job where I have to often install and test on my machine sample application I get from customers, unfortunately I found myself in this situation more than once and luckily in those occasions I’ve been saved by the by System Restore feature available in Windows XP. When a while ago I decided to switch on Windows 2003 as my primary working machine, and I then needed to restore the system to a earlier point, I discovered that System Restore is not available in our server platform… but I didn’t want to give up that “parachute” which saved me so many times (but not in that occasion… that is a lesson I learnt in…
-
I’ve been tagged :-)
So… this seems to be the game of this New Year (not really sure when it started, though)… Doug tagged me, so I’m now supposed to tell you 5 things you don’t know about me… here we are: I come from a completely different background: I studied Organ and Composition at the conservatory of Parma; do you know the “Ham of Parma“, or the “Parmigiano Reggiano” cheese, the “Parmalat” (sadly known for a huge financial disaster 3-4 years ago, as the “Italian Enron”) or Giuseppe Verdi? Well… I come from that land (an by the way, the native house and village of Verdi is just 5 minutes from the house where I grown up and lived for about 28 years… maybe that is what influenced my choice). Speaking of my favorite music, I’m an ancient guy (meaning I most like the Renaissance, Baroque and Classic eras, from W.A.Mozart backward), but of course I also don’t dislike some melodic “modern” songs… for sure I don’t like Heavy Metal and Techno Music (the latter can be really called “music”? C’mon… that’s just noise!) Computers where one of my other passions (together with painting, photograph, reading, movies and studying foreign languages), so towards the…
-
ClickOnce fails to download updated files while they are accessible from IE
An interesting problem I had a few weeks ago was about an application deployed with ClickOnce; the auto update failed with time out errors even though the updated files could be reached successfully via Internet Explorer. Also, it appeared to be possible for Administrators to successfully auto update the application. A network trace showed that ClickOnce tried to go out on the Internet to reach the server from where to download from; ClickOnce didn’t recognize the proxy settings for the user while Internet Explorer had no problems with that. After some digging into customer’s configuration we found that they were using an IE policy deployed via Active Directory called “NoProxy” where the hosts were separated with commas (”,”) instead of semicolon (”;”). The ClickOnce technology seems to require more stringent proxy setting formatting and did not recognize the commas as separators. CheersCarlo