TechDays 2012: a look at what’s new in ASP.NET 4.5


Microsoft’s flagship technology for almost 10 years, ASP.NET is gaining another half a level this year: it is now in version 4.5. This session was presented by Thomas Jaskula.

HTML5 in target, lighter JavaScript, even easier coding, Thomas Jaskula presents us with a few selected pieces of what awaits us, .NET web developers, in a few months.




Data binding controls become a real pleasure!




Data binding is greatly simplified and above all made more reliable.
No more strings to bind data to controls.
The new ModeleType property of bindable controls allows to strongly type the control.
Then, you just have to access the properties of the binded object via the Itemobject :


What was done before using OnDataBound events in the code-behind will now be done in a much easier way directly in the aspx while guaranteeing the integrity of the code with the object model preserved and the flexibility of writing with auto-completion.
The use of the object rather than strings to define the binding also ensures a better performance, the reflection not being necessary any more.
The methods for retrieving/updating data can be defined directly in the control definition in the aspx :
                            ID
                            =
                            "categoriesGrid"
                            runat
                            =
                            "server"
                            
                              
AutoGenerateColumns = "false"
AllowSorting = "true" AllowPaging = "true" PageSize = "5"
ModelType = "WebApplication1.Model.Category" DataKeyNames = "CategoryID"
SelectMethod = "GetCategories"
UpdateMethod = "UpdateCategory" >

Where it starts to become really nice is that the method used by the control can use parameter attributes to link this parameter to another input, for example another control, a variable in session or a parameter passed in the url(querystring):
                            public
                            IQueryable
                            <
                            Product
                            >
                            GetProducts
                            ([
                            QueryString
                            ]
                            string
                             keyword
                            )
                            
                              

With all this, as a bonus, we get a gridview that is able to sort/paginate itself, without any line of code to add. What do the people want?

A gadget for html encoding
No more excuses for not encoding unsafe strings: a new facility allows you to bind an automatically html-encoded field:
                            <%#:
HTML 5 for all !
In bulk :
  • the TextBox’s TextMode=”Email” which allows you to validate an email (and others) with HTML5 sauce, and hop some JavaScript less in the page,
  • the HTML5 compatible UpdatePanel
  • the FileUpload which manages the sending of several files
Asynchronism, could we escape it?
If there is a term that we should remember this year, it is probably asynchronous.
ASP.NET had to have its share of asynchronism.
It is now possible to implement completely asynchronous Modules and Handlers.
There are also new methods for reading/writing asynchronous streams on Request and Response objects.
Back to the future ?
HTML5 obliges once again, the last presentation concerning ASP.NET is not the least: the support of WebSockets.
Thomas Jaskula gives us a very simple but very efficient demonstration:
  • A browser that opens a connection (one line of JQuery) in TCP socket (in connected mode, so no more HTTP) on the server (2/3 lines of C#).
  • The server broadcasts all the messages it receives to all the clients that are connected in WebSocket.
It reminds the good old memories of C classes where we learned the network by coding a chat.
So obviously the question on everyone’s lips: how will the servers hold the load if the developers start opening sockets at all costs?
The question remains, it’s a technology that has potential, but to watch…
In conclusion

Like the message that Microsoft wants to convey globally during these TechDays, ASP.NET tends resolutely towards the opening. This is rather good news and the dynamics brought by ASP.NET MVC only enriches things.

Images and snippets from : What’s New in ASP.NET 4.5







Leave a Comment