Every now and then we get calls from a customer who decided to migrate his application from ASP.NET 1.1 to 2.0 (and sometimes those are mission-critical ones…) just changing the relevant mappings in IIS console, to then discover that the application is no longer working, or has some quite weird behavior which gives them headaches… Luckily that was not the case of the call I’ll now talk about; to test if the application could work against ASP.NET 2.0 the customer made the very quick test described above: they simply changed the mappings through IIS console and immediately notice that something was going wrong inside the app. They started troubleshooting the problem themselves and have then been able to repro the same problematic behavior inside a minimized application, just a simple .aspx page with some very basics functionalities in there (just a page with a command button and a GridView to fill with some data coming from Sql Server). This minimized repro was working fine on the dev machine with Cassini, but once installed in the target web server (Windows 2003 with IIS 6.0); when browsing with IE, the resulting HTML lacks completely the client-side Javascript to trigger the postback (while…
-
-
Need to pass cookies between machines on the same LAN?
Then in your web.config use an authentication section similar to the following: <authentication mode="Forms"> <forms name="myCookie" timeout="20" loginUrl="Default.aspx" defaultUrl="Default.aspx" protection="All" path="/" requireSSL="false" slidingExpiration="true" cookieless="UseDeviceProfile" domain="domain.com" enableCrossAppRedirects="true" /> </authentication> Internet Explorer will only pass cookies from one site to another if they have the domain cookie attribute set; i.e. the Fully Qualified Domain Name is required. Moreover all GET/POST must use the FQDN, as any Response.Redirect. The reason behing this is security, to make sure that a cookie is not passed to another site, thus exposing to cookies stealing. Carlo
-
Are you profiling your application and now you can’t debug anymore?
This is an interesting case I got very recently and that made me scratch my head a lot, wondering what was going wrong on customer’s machine for a while… until I called Doug on the rescue and we (he) drove the call to an happy ending 😊 I got this case from a colleague on the Visual Studio team; the customer reported a weird problem with the debugging of their ASP.NET 1.1 application (with Visual Studio 2003): when trying to step into the code line by line with F11, the debugger actually stopped only on the signature of every method skipping completely the body of the method, and to add something more, this happened only when they were using a specific namespace (e.g. MyCompany.MyNamespace.Group); if they used the same exact code but in a different namespace, everything worked fine 😲. Moreover, this was happening on that very specific web server only, if they moved the code to another machine the debugger worked like charm (but moving to a different machine was not an option for them). My first thought went to the .pdb files, some kind of mismatch between the between the code esecuted in memory and the symbols used…
-
Windows Control Library does not resize correctly if you change IE window size
Hosting a Windows Control Library control in an ASP.NET 2.0 page, the WCL does not resize correctly, if you change the size of the IE Window. The problem does not occur using .NET Framework 1.1 The problem is a regression in Visual Studio 2005 which prevents the .Net ActiveX implementation from asserting managed code privilege when calling IOleClientSite::OnPosRectChange. Since that call requires managed code execution privileges, it fails and the control cannot resize itself. The workaround is to set the size of the control from the HTML rather than resizing it internally. For example, the onresize in the body tag in the following script does this: <html> <body onresize=”obj1.Width=document.body.clientWidth;”> <div style=”width:100%;height:100%;background-color:blue”> <OBJECT id=”obj1″ height=”90%” width=”90%” classid=”MyResizeControl.dll#MyResizeControl.UserControl1″ VIEWASTEXT /> </div> <br> This is a long string for me to test the other space </body> </html> Capitalization of the properties is important: capital “W” (Width) will correctly change the Width property of the internal .Net control; lowercase “w” (width) will change the property of the HTML object rather than the .Net object, and this will not work if the .Net object is 1.1. Cheers
-
If an EventHandler is called twice…
…take a close look at your code 😊. This comes from a case I worked on in the last couple of days: a customer reported a problem in one of his ASP.NET 2.0 pages, which is meant to perform some sort “long running” operation on the server. What puzzled me a bit (well… quite a bit, at the beginning) is the fact that after the user clicked posted the page (clicking on a submit button) and the long operation begun on the server, after about 90 seconds they noticed a new click button for the submit event was fired, thus restarting the whole “long” operation (and of course leading of all sort of problems this implies for the application’s logic). Doing some tests we found that more that the above, even if he closed the browser on the client immediately after submitting the form, after about 90 seconds they still got a second click event firing for the submit button! 😲 Of course if the browser is closed on the client, it’s hard to believe that the new click and subsequent post is coming from the user… 😏 We looked and the page source produced by the server, here is an interesting excerpt: <input type="button"…
-
Charting in ASP.NET (alas: GDI+ not supported in a service)
A few weeks ago we had an interesting discussing in my team (triggered by a customer’s request for some hints on charting in ASP.NET) about the use of GDI+: here is what the documentation states on the subject (and what spurred the customer on opening a Service Request with CSS): Classes within the System.Drawing namespace are not supported for use within a Windows or ASP.NET service. Attempting to use these classes from within one of these application types may produce unexpected problems, such as diminished service performance and run-time exceptions. (from http://msdn2.microsoft.com/en-us/library/system.drawing.aspx) Just to clarify: they were not experiencying any particular problem and you can go with GDI+ if that workes fine according to your requirements, but the statement above means that CSS can’t help you if you are running into troubles with it… Customer concern and question: Searching the internet, most of the samples for ASP.NET applications providing charting work with GDI+; there are even books on this topic. Why Microsoft is not supporting GDI+ in ASP.NET? If we want to build charts on our own, what design can we use which Microsoft DO support? Well… GDI+ ins’t supported from a service because those components/classes where not designed/tested to run without an interactive desktop in a…
-
Advanced ASP.NET 2.0 and deep dive Ajax training
Last week I attended an advanced ASP.NET 2.0 training with deep Ajax dive in our sub in Munich; for my convenience I flew in on Monday morning (I had to wake up at 4 a.m. to go to the airport 🤭), jumped on a S-Bahn train to the station of Lohhof and after that I had almost no idea where to go exactly because that was my first time there, but right out the station there is a nice road sign indicating “Microsoft –>” 😊, and then signed-in right on time for the first day start. It was a Develop Mentor training set up just for us CSS Engineers (well, actually the only 5 attendants are all from my virtual team 😲); the weather in Germany has been quite bad, lots of rain and icy wind (I actually got a cold with a temperature, a cough… all the stuff 🤒), all the hotels in town where full because of some kind of industrialists meeting (not exactly understood what) so I had to accept the only with some rooms available… not a good experience for my first time in Germany, but at least the training was well worth all of those troubles!…
-
Watch out your Web Events!
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…