Web Platform User Group - ASP.NET Frameworks Comparison

by Ventsy Popov

A couple of days ago a Web Platform User Group meeting was held at Microsoft Bulgaria's office. It was a well attended discussion and I hope also a useful one. The topic was “ASP.NET Web Forms vs. ASP.NET MVC vs. ASP.NET Web Pages” or shortly called “ASP.NET Frameworks”.

Although we were sure the above technologies were already familiar ones, the point with this meeting was to see if we can consider some rules and questions that will help us decide when to use one instead of another. In a very brief way here is what we talked about:

ASP.NET Web Forms
A mature (and the oldest of the three) technology aimed mainly at rapid development, simulating stateful model of the Web. With its postback and event-driven model provides a small learning curve when a windows forms developer should transfer to web forms.

ASP.NET MVC
MVC pattern-based architecture of the developed applications. Allows developers to have very fine tuning control over the final HTML. SEO inclined with clear separation of concerns of the system components and TDD oriented.

ASP.NET Web Pages
Have the same full control over HTML as with the ASP.NET MVC case and uses Razor syntax. WebMatrix is a small and free IDE tool for Web Pages completing the whole idea for simplicity of this web development case. The main target here is not using commercial development products when you need to create a relatively small web site for demonstration, education, and in rarer cases commercial purposes.

Here are the full presentation: WPUG_ASP.NET_Frameworks.pdf (540.94 kb) and demos: WPUG_ASP.NET_Frameworks_Demos.zip (3.36 mb)  for more details.


ASP.NET | Presentations

Sofia University - ASP.NET State Management

by Ventsy Popov

As developers we are quite often put in a situation of trying to find the right solution of a currently emerging problem. The immense information we have at hand (eyes) with internet might not always be useful, instead if you think about it, it can be in a way a bit wicked… Wicked so that it makes us copy and reuse ready-made fragments which leads to our tasks being finished as soon as possible. What I am trying to imply is that if we want to reuse our own knowledge, we should try to be aware of the fundamentals of the technologies we utilize.

Some of the basic, yet important aspects of ASP.NET state management a developer should have in mind: 

  1. Try to see the whole picture of state management in web applications in general (cookies, hidden fields, parameterized addresses)
  2. Then above all – know a page lifecycle. It comes very handy when you wonder what is executed first, the button click event handler or the page load one :).
  3. What comes next is see what goodies we have in ASP.NET in particular – view state, application state, session state
  4. Last - you can check how to manipulate request/response objects in .NET

A presentation from a Sofia University course referring to the above matters:  ASP.NET-State-Management.pdf (12.48 mb)
…and the demos for it: State-Management-Demos.rar (44.68 kb)


Presentations | ASP.NET

Elieff Center for Education and Culture - PHP on IIS

by Ventsy Popov
A while ago I was called by my boss Vladimir Tchalkov on the  phone with the offer to cover for him on a talk he had to give. I say an "offer", since I have to be honest and admit, that it was more of an opportunity for me, than doing a favour to Vlado who had an urgent travel to make at that time... In other words - something of a win-win situation for both of us. The topic was "PHP Applications Hosted on IIS" and although I had literally no time to prepare, most of the work was already done for me. With some counseling by Vlado and fooling around with test application I was ready to launch :).

The talk was actually part of a small Microsoft event about PHP integration in Microsoft technologies. The other presnetation on this topic was made by Svetlin Nakov. Since the audience consisted more of PHP guys than .NET ones, we kinda had to convince them there is a real deal in using PHP along with Microsoft products... Hope at least we inclined them on the idea of giving it a shot :).

 Here are some strokes of the raw material on my side of speaking:

CGI and ISAPI 
Although CGI is a relatively easy way to delegate the generation of a web page to an executable it comes at a certain cost. Every time a command is called we pay the price of creating a new process, which can be a bit of a performance drawback.  ISAPI extensions on the other hand could be real fast (guessing they where developed properly), but require thread safety to be separately taken into account. On the top of that we cannot use scripting languages to create ISAPI extensions (or filters).

 

Here comes FastCGI 
Which we can say combines the good sides of both of the above:
 - A process is created on a first request, and then reused. Hence it is very fast.
 - Has a single-threaded execution, which is recommended for NON-thread safe PHP applications. This way we can count on stability as well.
 
How to Install
1) Well you can use Web Platform Installer and with just a few clicks have your environment ready,
or
2) You can head to a more tedious process of doing it by enabling FastCGI on IIS, downloading the latest version of PHP for Windows, and configuring IIS to handle PHP requests.

Good To Have in Mind  
After installing you might want to check out the web.config and configure the maximum requests being served, before a process is recycled, and adjust the maximum instances of a process ran on a single processor:

<fastCgi>
<application fullPath="C:\PHP\php-cgi.exe"    
	maxInstances="4" 
	instanceMaxRequests="10000"
	idleTimeout="300"/>
</fastCgi> 
 
Here is the full presnetation for PHP Applications on IIS.

Presentations

Sofia University - Design Patterns course (Facade)

by Ventsy Popov

I intend to start something of a personal initiative and upload some materials on talks I held. Hopefully they can be useful to others. One of the courses I eagerly participated in was on the subject of Design Patterns a couple of years ago.

Façade was the first topic I had to cover and the talk was very well accepted by the students in Sofia University, even though I had very little experience in public speaking back then. Thinking about it - good preparation plus some funny moments played the main role for that. As for the more technical aspect of it, I will try to lead you through the main idea of the pattern:
From time to time it might happen that we come across a complicated system (in terms of being highly coupled) and we should somehow plug into it and use its features. God forbid the system was not developed by us, and then the misery is doubled :). Let me illustrate what I mean:


 

If we are in the tough position of creating the client, we will bump into:
   - the complexity of such a base system;
   - the high coupling of the classes;
   - the difficulties we hardly can foresee in supporting such a monster :).
So what we can do is, expose only the functionality we need for our client and in a way – forget about the rest of the hairy base system, reshaping the sketch like this:

 

In such way we can create a separate level of abstraction, which is much more easily “absorbable” by us developers.

Here is the presentation FacadePattern.pdf and the demos FacadeDemos.zip. Having in mind the source code is very minimalistic example of a Façade pattern implementation – enjoy :).


Presentations

Sofia .NET User Group - Open Data Protocol (OData)

by Ventsy Popov
Recently I had a talk for the Sofia .NET User Group.  Actually it was my first speak for the user group and I was happy to see that after a couple of years of irregular gatherings, folks are still interested in these events. Nadya Atanasova who is lately the main engine for organizing us geeks, is doing a great job in promoting the meetings.

The topic of my speak was Open Data Protocol and WCF Data Services. With a few surprises - for example video recording with Microsoft Live Meeting (which I happened to have no experience with), we were able to start and cut to the chase :). First we travelled a bit in time, tracking the history of OData through Astoria and ADO.NET Data Services until it became a separate web protocol. After that we pulled some data out of Netflix (super exploited jQuery and OData example by the way :)):
       $(document).ready(function () {
            $.getJSON("http://live.visitmix.com/odata/Sessions?$filter=SessionID%20gt%20200&$format=json&$callback=?",
        function (data) {
            $.each(data.d.results, function (key, val) {
                
                var str = '<h3>' + val.Title  + '</h3>' + val.Abstract + '<br/>';

                $(str).appendTo('#images');
            });

        });
        });

And of course in honor of Microsoft, we played with a little C# code, implementing a simple WCF Data Services with exception handling:
    public static void InitializeService(DataServiceConfiguration config)
    {
        config.SetEntitySetAccessRule("*", EntitySetRights.All);
        // config.SetServiceOperationAccessRule("MyServiceOperation", ServiceOperationRights.All);
        config.DataServiceBehavior.MaxProtocolVersion = DataServiceProtocolVersion.V2;
    }

    protected override void HandleException(HandleExceptionArgs args)
    {
        args.Exception = new DataServiceException(
            args.ResponseStatusCode,
            args.Exception.InnerException.Message);

        base.HandleException(args);
    }
You can check out the slides and demos:

Presentations