ASP.net 2.0 Looking Pretty Slick

First a disclaimer: I have never used Visual Studio 2005 (except for an early beta Express edition) nor have I used ASP.net 2.0 (I plan to start in the next couple of days). I have been doing lots of ASP.net programming and application development using the .Net Framework (1.14322), C#, VS 2003 and SQL Server 2000.

That said, I am getting personally excited (in a professional way) about the improved development potential with ASP.net 2.0

A few things that I have seen recently that have influenced my opinion enough to write the previous sentence:

  • Scott Guthrie has posted an account of how MySpace is using ASP.netand how switching to the new platform (fresumably from ColdFusion) affected their performance:
    • They are processiong 1.5 billion page views per day, reaching 2.3 concurrent users
    • After switching to ASP.net 2.0, their server utilization went down from 85% to 27%!

    So if you are considering the platform, you wont have to be concerned about any scaling or performance issues (assuming you know what you are doing). (I wonder how php would compare, with caching and everything else. Would it even be 50% as efficient as pre-compiled code? 30%?)

  • The ATLAS framework has just received a go-live license with its March CTP release. ATLAS is Microsoft’s version of Ajax for ASP.net. It may not be ROR, but if you check out this demonstration video (worth watching for both the ATLAS demo as well as the demonstration of the new improvements to the product that make development go faster) I hope you will agree that it is definitely something worth trying out.
  • For just a quick taste of other features touched by the upgrade (as well as totally new additions), check out some of the webcasts on the ASP.net Developer Center

They may not ship everything on time…but once they get their products out the door, they (often?!) can really shine.

Bitkraft

From the website:

Bitkraft is a CLR based (.NET) web framework that allows distributed web content to be created and served in a unique fashion. It is written in C# and compiles for operation under the Microsoft .NET Framework 1.1+ or the .Mono Framework, making it portable to almost any platform.

At it’s core, the Bitkraft framework extends the ASP .NET Architecture to fully support Javascript-based Server callbacks using the XmlHttpRequest object as a transport layer in a fashion referred commonly today as AJAX (Asynchronous Javascript Over XmlHttpRequest). There are many “AJAX” frameworks available today however, the Bitkraft framework is unique in the way that it seeks to blur the lines between client (browser) and server and the manner that it allows the development of truly Smart Web-Based applications that intelligently distribute their functionality between Client and Server in a seamless manner.

Looks like a very cool method for implementing asynchronous client-server web development.

Forget the Password for IUSR?

I was changing around the Directory Security for an ASP.net page. In the process of doing this, the IUSR account was removed. After fixing the problem, I wanted to set the Anonymous Access for the website back to IUSR. Unfortunately, I needed the password for the IUSR account in order to do this.

WindowsITPro has a great solution posted for retrieving the username and password information for IUSR.

Just in case that link ever goes down, here is the solution: Take the following code, save it in NotePad as a .vbs file and run it.

Worked like a charm

Web Reference URL Behavior

So I created a Windows Service (based on this) that is designed for one purpose: to call a Web Service on my ASP.net application every 2 minutes that will perform certain jobs (like sending emails, other maintenance). In the config file for the service there is an appsetting labeled <add key=”Namespace.WebServiceName” value=”http://WebServiceAddress/JobRun.asmx”/>.

According to this article, by changing the key for this appsetting before installation of the Windows Service, the Windows Service would call the Web Service identified by the key. So it was written.

In the the Solution Manager in VS 2003, there is a Property under the Web Service called “URL Behavior”. This can be set either to “Static” or to “Dynamic” (see here for more official info).

  • When set to Static, the URL that is entered for this Web Service when the Web Service is first referenced in VS is the url that will always be used.
  • When set to Dynamic, the Web Service will always use the URL located in the config file | appsettings.

Obviously, in order for the Windows Service to function properly (ie: call the Web Service that is indicated in the Config file), the URL Behavior property of the Web Reference must be set to Static. Unfortunately for me, during my editing of this file and changing of the Web Reference, I forgot to set my Web Reference from its default behavior of Static to its correct behavior of Dynamic. Thus wasting many of my hours and killing many of my brain cells. Don’t let it happen to you.

Keep ASP.net Session Alive Indefinitely

This article from The Code Project gives instructions on how to set up your ASP.net project so that as long as the user is logged in with the browser set to your site, the page will automatically refresh a few second before the session will expire (and will continue to do so indefinitely, as long as the user remains on your site).

The best part is that it is just two lines of code:

private void Page_Load(object sender, System.EventArgs e)
{

Response.AddHeader(“Refresh”, Convert.ToString((Session.Timeout*60)-10));

}

Read about The Session Defibrillator for more implementation information.

Combine Web and Windows Services to Run Your ASP.NET Code at Scheduled Intervals

See the article with this title from MSDN Magazine’s March 2005 issue.

The basic flow of the article:

  1. Create a Web Service that will be called to run the jobs
  2. Create a Windows Service that will call the web service at specified intervals. Create installation package.
  3. Create classes that inherit from a Job class for each job that will need to be run
  4. Set up interface with database to store job timing, populate the job classes when needed
  5. Hook up the jobs to the web service

It does seem to be a little bit more complicated than is needed (the core of it all is the Web Service and Windows Service). However, it does give a very scalable solution for scheduling jobs in ASP.net – once the initial setup is defined, adding jobs will be pretty simple and it should work pretty well.