Thursday, April 26, 2007

ASP.NET progress update before 1.2.4

It's been a while since the last update, and I think it's worth mentioning that ASP.NET 2.0 support in Mono will get much, much better with the upcoming 1.2.4 release. The release notes contain a bit of information but there is a lot of little changes hidden behind the bigger ones. Most of work in the past months went into fixing small incompatibilities that were popping out all over the map.

One of the most important highlights of the next Mono release as far as ASP.NET is concerned will be, in my opinion, the fixing of an XSP problem with overlapped requests that resulted in exceptions thrown and requests failed. It took a fair amount of testing to pinpoint that one, but it's gone. In addition, ASP.NET performance has doubled for 2.0 applications, mainly thanks to getting rid of heavy-weight code to detect whether the visiting browser supports JavaScript.

The new code relies on the idea that the browser's UserAgent string (as unreliable source of information as it is - but we have no other choice) can be used to detect similar browsers with enough accuracy to "check" if JavaScript is there or not. New utility, called cuplevel (CompileUplevel) was added which takes an XML description of JS-capable browsers and compiles it into ugly, but fast, matching code. The code is able to match over 90000 of unique UserAgent lines in less than 0.02s, which is quite fast.

To make sure that our JavaScript scripts still work correctly, the checks for ECMAScript and W3C DOM capabilities have been moved from the class library to the scripts themselves (where they really belong). This may result in small parts of the script not working on certain browsers, but the rest of the script will continue working - unlike previously when no script was ever output to the client if the class library failed to detect that ECMAScript is supported.

In a word - do try 1.2.4 when it's out (or even grab a copy now), test it with your favorite 2.0 application and file reports on any bugs (even the smallest ones) you can find!

Sunday, April 15, 2007

ASP.NET - convert a physical path to virtual path

I've seen this question asked several times on forums with many different answers provided. Here's another way to achieve that goal.

If you are 100% sure that your file is below your physical application root, you can just do the following:

virtualFilePath = physicalFilePath.Replace (HttpRuntime.AppDomainAppPath, "/").Replace (Path.DirectorySeparatorChar, '/');