Monday, June 11, 2007

TechEd - AJAX Performance Tips

The presenter for this topic was Jeff Prosise.

Probably the most popular control with the new ASP.NET AJAX functionality is the UpdatePanel, but unbeknownst to most developers, including myself until I attended this session, was that the UpdatePanel is not that great performance wise.  It is still better than a post back but since the UpdatePanel has to send back the entire ViewState there is not that much on performance gains.

Here are some tips when using the UpdatePanel:

  • Set the UpdateMode property to conditional.  This will cause any controls that does not need to update to not ask to be updated.  Call the UpdatePanel.Update function when you need other UpdatePanels to update.
  • Eliminate unnecessary rendering.  Only include the controls you want to update in the update panel.

The better approach altogether is to forego the UpdatePanel completely and use the Sys.WebForms.PageRequestManager instead.  This control is the client side version of the update panel and it allows more control of the asynchronous updates such as prioritizing overlapping updates, canceling updates before they occur, canceling updated as they occur, and highlighting update panels.  You can see what functionality it has here.  Although it is more work for the developer, there is no view state and no lifecycle page processing so there is far greater efficiency.

Here is a code example from the demo:

<asp:Button ID="CancelButton" Runat="server" Text="Cancel" OnClientClick="cancelUpdate(); return false" />

...

<script type="text/javascript">

function cancelUpdate()

{

var obj = Sys.WebForms.PageRequestManager.getInstance();

if (obj.get_isInAsyncPostBack())

   obj.abortPostBack();

}

</script>

TechEd - Visual Studio 2008 IDE Enhancements

The next version of Visual Studio will have some cool new features here are some of the highlights:

  • The new version VS will allow you to target which framework you want to code and build to (i.e. 2.0, 3.0, 3.5).  Picking the appropriate target will activate or deactivate which features you can use.   Note:  To upgrade a 2.0 website will only require changing the framework target and will not require a complete solution upgrade as was the case in the past.
  • The changes in the HTML designer are huge.
    • Fast designer/source switching.
    • The split view designer.  They finally have caught up with Dreamwearver with this feature.  Dreamweaver has done this since forever.
    • Nested master pages.  You now have a page that inherits from a master page, which itself inherits from a another master page.  So you one master page for a very top level look and feel and then for say a certain section of a website have a nested master page with a more specific look and feel for a sub-group of web pages with in a website.
    • An upgrade to the CSS designer.
  • JavaScript debugging and intellisense.  We have already had certain degree of JavaScript debugging but the new version will take it to next level and now with intellisense.  Also the complete foundation of ASP.NET AJAX core JavaScript functionality will include:
    • JavaScript type system
    • JavaScript <-> .Net Networking Serialization
    • JavaScript library of common utilities.
    • ASP.NET Server Control integration.
  • The JavaScript debugging functionality will now include breakpoints in aspx files and not just during runtime and new a new visualization feature for variables (You can click the little "plus" sign and it will expand the items in the object just like you can do with a .Net variable).

Saturday, June 09, 2007

TechEd - LINQ Presentation by Scott Gunthrie

LINQ is the new functionality coming out with Visual Studio 2008 that makes querying data a core programming concept.  It can work with direct connection to a relational database or querying XML, although VB.Net has much more functionality in the XML area, which I think is a shame because I think that most developers now are using C#. 

For example you can copy and paste XML directly on a VB file and Visual Studio will recognize it as XML.   You cannot do that with C# yet which is a big bummer because I am a C# programmer and see a lot of uses for that type of functionality.

For more details on LINQ check out Scott Gunthie's site.  He is the General Manager of Microsoft who gave one of the demos on LINQ.

I went to two demos and took a lab on LINQ and I really think this is going to create a paradigm shift for developers.  I think the days of creating stored procedures in databases are coming to end.  With the advent many different OR mapping tools like nHibernate and now LINQ hitting the seen and all of them dynamically creating SQL on the fly, why spend time writing stored procedures?  

The whole thought behind the need for writing stored procedures was that it was more secure and it was faster.  Regarding security, you will have to be careful not to allow SQL Injection but once you are past that you are secure.  Regarding performance; everything I am reading and hearing is that it really does not make that big of a difference if you query is inline or in a stored procedure.  Plus having LINQ generating the query statements for you takes the DBA out of the picture making the application easier to deploy.

TechEd - RSS Platform in Internet Explorer

The great thing about RSS Feeds is that it allows you to push content to users in a more desirable way than sending them spam. RSS feeds are subscribed to by the users so it lets them keep control. It also allows them to view content at their own discretion, even offline.


Much of the content below was taken from Eric Lawrence's presentation and his slides on the subject.


With the new Internet Explorer 7.0, you can now light up the RSS tool bar button. This allows the users to subscribe rather easily. You just need the following link:

<HTML>

<head>

<link rel="alternate" type="application/rss+xml" title="My RSS Feed" href="myrssfeed.xml" />

</head>

...

</HTML>

There are two types of RSS feeds (logs and lists)













Type LogList
ContainsRecent n itemsSnapshot of full list
Order ByPubDateItem position
Item RemovedNot segnificantSegnificant
Change of OrderNot segnificantSegnificant


Here is how you specify a list for Internet Explorer 7.0


<channel>

<cf:listinfo>

<cf:sort name="element" ns="namespace" data-type="datetextnumber">
User-readable name for the element

</cf:sort>

<cf:group name="element" ns="namespace">
User-readable name for the group
</cf:group>

</cf:listinfo>


cf: sort enables you to specify an element to sort on.

cf: group enables you to specify an element to group by.

The CF namespace is defined as an attribute of the RSS element.

xmlns:cf="http://www.microsoft.com/schemas/rss/core/2005


With the above content and if a user is using IE 7.0 they can get a user friendly toolbox.


For more information on the subject check out the IE RSS 2.0 Blog.

http://blogs.msdn.com/rssteam/archive/2007/06/06/rss-2-0-best-practices-profile-draft-released.aspx

Thursday, June 07, 2007

TechEd - Windows Communication Foundation

This class was taught by the guy who literally wrote the book ("Programming WCF Services", O'Reilly) on WCF, Juval Löwy.

WCF is a SDK for building SOA on Winodows. It is part of the Microsoft 3.0 Framework which ships with every Vista machine. It also requires the 2.0 Framework.

WCF is essentially Microsoft's next version of asmx pages and .Net Remoting, the difference being the service plumbing is totally abstracted from the developer and placed in the configuration file.

It can use the following transport methods.

  • HTTP
  • TCP
  • P2P
  • IPC
  • MSMQ


The address is specified in the following syntax:

[transport]://[machine or domain][:port]

The programmer only has to assign some attributes to class he/she wants to expose and the framework does the rest. The developer would create an interface for the object they want to expose and the a concrete class which implements that interface.

For example:




[
[ServiceContract]
interface IMyContract
{
[OperationContract]
string MyMethod(string text);

//Will not be part of the contract
string MyOtherMethod(string text);
}
class MyService : IMyContract
{
public string MyMethod(string text)
{
return "Hello " + text;
}
public string MyOtherMethod(string text)
{
return "Cannot call this method over WCF";
}
}

The service must be hosted in a Windows process and a single host process can host more then once service. Once you select a host you then need to select a binding.

The binding is the mechanism for abstracting all of the piping out your code. In it you specify:

  • Protocols
  • Format and encoding
  • Security
  • Reliability
  • Transportation propagation
  • Interoperability

There is a great decision tree diagram of when to choose which type of binding which I will try and provide later.

Here is a sample of what your config file would look like:





address = "http://localhost:8000/MyService/"
binding = "wsHttpBinding"
contract = "MyNamespace.IMyContract"
/>
address = "net.tcp://localhost:8001/MyService/"
binding = "netTcpBinding"
contract = "MyNamespace.IMyContract"
/>
address = "net.tcp://localhost:8002/MyService/"
binding = "netTcpBinding"
contract = "MyNamespace.IMyOtherContract"
/>


Tuesday, June 05, 2007

TechEd - SysInternals

If you have not heard of Sysinternals, it is great software site recently acquired by Microsoft which hosts a litany of diagnostic tools you can use to troubleshoot performance problems you might be having a server or even a personal PC.

The great thing about these tools (taken from the presentation):
  • There is no install required
  • Can run from a remote file share
  • no garbage left behind
  • small registry foot print
  • single exe
  • and other reasons...

The tools are divided in these categories:

  • File and Disk
  • Networking
  • Process
  • Security
  • System Information
  • Misc.

The most downloaded tools are:

  • Process Explorer - which is the windows task manager on steroids. One neat thing about this tool is you can set up history for each process.
  • Autoruns - which is great tool that allows you stop processes which were installed by programs that force themselves to be started on every start up.
  • Process Monitor - is a log of each process which records and entry each time a process is triggered.

Key Note

Bob Muglia, Senior Vice President of the Server and Tools Business (STB) gave the key note address along with other speakers who presented demos on the some of the new technologies that will be released this year.

All the keynote itself was somewhat dull there were some pretty interesting announcements that were made.
  • Windows Server 2008 (code names "Longhorn") will be released on time in the second half of 2007.
  • Visual Studio 2008 (code named "Orcas") will be released by the end of this year also. Scott Gunthry did not want to specify but he believed before Labor Day.

I'm at TechEd!

Well finally got myself connected to web to share the great sessions I have been to. I guess it is better late than never. My hotel Internet access in my room is broken so I have add to connect here at the conference.

In next few posts I will be sharing about the specific sessions I have been to so hopefully you will find them interesting and informative.