Labels

Wednesday, March 24, 2010

WCF Hosting Options & Transport Protocol Support

There are multiple hosting options present.

 

·         IIS Hosting

·         Self Hosting – Via

o    Console Application

o    Windows Host application

o    Windows Services

o    WPF

·         WAS

 

IIS supports hosting over HTTP protocol only.

WAS supports hosting over any protocol.

Self-Hosting also supports hosting over any protocol. However there are few exceptions. Please refer below table.

 

Note: Selecting a host environment has nothing to do with the ‘Sevice Implementation’ code, but with the ‘Service Deployment’.

 

These different hosting options support different ‘Transport Protocols’, based on the operating Platform.

 

Operating System

Protocol Support

Hosting option

Windows XP/SP2

HTTP

IIS 5.1, Self Hosting

 

Named Pipes, TCP, MSMQ

Self Hosting

Windows Server 2003

HTTP

IIS 6.0

 

Named Pipes, TCP, MSMQ

Self Hosting (only Windows Services)

Windows Vista

HTTP, Named Pipes, TCP, MSMQ

WAS IIS 7.0, Self Host

Windows Longhorn Server

HTTP, Named Pipes, TCP, MSMQ

WAS IIS 7.0, Self Host

 

 

 

 

 

Hope this helps.

Arun

 

 

Tuesday, March 23, 2010

Microsoft Ajax Minifier

Introduction:

 

·         The Microsoft Ajax Minifier is a free tool that you can use to minify your JavaScript and Cascading Style Sheet files.

·         The minifier utility that allows you to shrink/minify both JavaScript and CSS files – which can improve the performance of your web applications. 

·         You can run this either manually as a command-line tool or now automatically integrate it using a Visual Studio build task. 

·         You can download it for free here.

 

There have been a number of utilities out there for “minifying” JavaScript. Read More..

 

Microsoft Ajax Minifier by default will try to reduce the code as much as possible: removal of comments, whitespace, and unnecessary semicolons and curly-braces; renaming of local variables and functions to shorter names; and removal of unused or unnecessary code. The -rename and –unused switches can be used to alter this default behavior.

 

Minifications:

 

Microsoft Ajax Minifier minifies script by parsing the source code into a JavaScript Syntax Parse Tree using code based on the ROTOR sources published by Microsoft. Once the original sources have been parsed, the tree is manipulated, and then walked to output the minimum amount of JavaScript code required to reproduce a comparable parse tree. Microsoft Ajax Minifier does not alter the source file.

Default minification are as:

  • Remove unnecessary white space.
  • Remove comments (except for statement-level “important” comments).
  • Remove unnecessary semicolons.
  • Remove curly-braces around most single-statement blocks.
  • Rename local variables and function.
  • Determine best string delimiters (single- or double-quotes) based on which option will generate the fewer escaped characters within the string.
  • Combine multiple adjacent variable declarations.
  • Remove empty parameter lists on constructors.
  • Remove unreferenced names for named function expressions.
  • Remove unreferenced local functions.
  • Remove many instances of unreachable code.

Few examples:

 

Origianl

Minified

if ( a == 0 )  

{  

a = 10;  

alert(b/a);  

 } 

if(a==0){a=10;alert(b/a)}

 

var a = 0;  

var b = "some string";  

var c = 3.14;  

 

var a=0,b="some string",c=3.14;

if ( a == 0 )  

 { 

     for(var o in opts) 

     { 

         if ( o > 0 ) 

         { 

             a += o; 

         } 

     } 

 } 

 else 

 { 

     b = c / a; 

 } 

if(a==0){for(var o in opts)if(o>0)a+=o}else b=c/a

function DivideTwoNumbers(numerator, denominator, unsedparameter ) 

    return numerator / denominator; 

}

function a(a,b){return a/b}  

 

 

 

Usage:

 

Two approaches:

 

·         Command Line

·         As a Build Task

 

Command Line: After you install the Microsoft Ajax Minifier, you can use the tool from the command line. Open the Microsoft Ajax Minifier Command Prompt from the Microsoft Ajax Minifier program group. Next, enter the name of an input file and the name of an output file like this:

 

ajaxmin test.js -o test.min.js

ajaxmin test.css -o test.min.css

 

Build Task:

 

·         You can integrate the Microsoft Ajax Minifier into your Visual Studio Build process.

·         Every time you perform a build in a Visual Studio ASP.NET project, you can minify all of your JavaScript and Cascading Style Sheet files automatically.

·         You can use the Ajax Minifier with both ASP.NET Web Forms and ASP.NET MVC Web Application Projects (WAPs).

 

Note: However, you cannot use the minifier with ASP.NET Web Forms Websites.

Read More to Follow the steps.

Hope this helps.

Arun

 

 

 

 

"Minifying" JavaScript

JavaScript has the dubious quality of not being compiled. The source code text for the program is downloaded by the client, parsed, and the interpreted by the browser. Verbose, easy-to-maintain coding styles actually hurts performance with JavaScript, as it Greatly Increases The Page Weight transmitted to the client.

There have been a number of utilities out there for “minifying” JavaScript.

 

·         The first level of minification is to Remove Whitespace And Comments. This is a minimum amount to be expected for a website – comments and whitespace can be extracted from the sources without changing the semantics of the code. The third-party tool Jsmin from Douglas Crockford (http://www.crockford.com/javascript/jsmin.html) is an excellent example of this kind of minification.

·         The second level of minification is to also Remove Excessive Semicolons And Curly-Braces. In JavaScript, semicolons are not statement terminators as in C or C#, they are separators. Therefore the final statement in a block does not require a semicolon after it. Curly braces, although highly-recommended for properly-maintained JavaScript code, also don’t need to be around single-statement blocks. We don’t have to send those bytes to the user, however, and they can and should be removed before deployment. Developers also tend to over-parenthesize their expressions in order to make them more readable or to ensure that the intended precedence will unfold as expected. Extra parentheses can also be removed from the output. The danger is that this level of minification could alter the semantics of the code if not done properly.

·         The next level of minification is to recognize the fact that Local Variables And Functions are referenced only within a known scope, and can therefore have their identifiers Shrunk Down To Shorter Names. This is highly useful because developers can code with longer, semantic names in their local functions and variables in order to increase readability and maintainability without having to penalize the client with large downloads. These modifications must be very carefully made because this level of change to the sources is greatly increased. Scope chains must be respected or the code will cease to work properly, and global variables cannot be touched (since they may be referenced from other script files).

·         The next level is to analyze the code and recognize & Eliminate Unreachable Statements And Functions, And Unused Variables. Eliminating these bytes from the download can go a long way to shrinking your page weight, without having to require constant manual reviews of the code base. Again, this must be very carefully done to ensure that a function or variable really isn’t referenced.

·         The next level of minification is to Analyze The Usage Of Global Variables And Object Properties, and to Provide Shortcuts in the code the replace the longer, repeatedly used constructs. For example, if the algorithm detects that a script repeated accesses the “window” global object, a one-letter variable can be set to the window object, and every other instance of “window” in the code can be replaced with that single letter. This not only modifies the existing sources, but also injects new code into the JavaScript. What can be replaced must also be carefully determined to make sure that the values and objects cached in the short local variables will remain the same value for the life of the variable.

 

Hope this helps.

Arun…

 

Monday, March 15, 2010

ASP.NET MVC 2 Finally Released

You can download and install it from the following locations:

 

Note : MVC 1.0 Release Date: 27th Jan 2009

 

The final release of VS 2010 and Visual Web Developer 2010 will have ASP.NET MVC 2 built-in – so you won't need an additional install in order to use ASP.NET MVC 2 with them. 

 

ASP.NET MVC 2 is the next significant update of ASP.NET MVC.

 

·         It is a compatible update to ASP.NET MVC 1 – so all the knowledge, skills, code, and extensions you already have with ASP.NET MVC continue to work and apply going forward.

·         ASP.NET MVC 2 can be installed side-by-side with ASP.NET MVC 1

·         Here are the instructions on how to update your existing ASP.NET MVC 1 apps to use ASP.NET MVC 2 using VS 2008 here

·         Note that VS 2010 has an Automated Upgrade Wizard that can automatically migrate your existing ASP.NET MVC 1 applications to ASP.NET MVC 2 for you.

 

 

ASP.NET MVC 2 adds a bunch of new capabilities and features. 

Here is the Scott Gu's blog series about some of the new features.  Some of the new features and capabilities include:

 

 

Important Links:

 

You can learn more about these features in the "What's New in ASP.NET MVC 2" document on the www.asp.net/mvc web-site. 

A lot of new tutorials and videos shortly on www.asp.net/mvc that cover all the features in ASP.NET MVC 2 release. 

An updated end-to-end tutorial built entirely with ASP.NET MVC 2 (much like the NerdDinner tutorial that I wrote that covers ASP.NET MVC 1). 

 

 

Hope this helps.

 

Regards,

Arun Manglick

Tuesday, March 9, 2010

Silverlight 3: Navigation URI Routing

Here we'll discuss about 'SL3 Navigation'.

 

One of the new features in Silverlight 3 is providing an application navigation framework via the Frame and Page controls in the APIs.  If you saw my guide to Silverlight 3, you may have seen the section on navigation which describes the functionality and as well has a link to a video tutorial about it.

 

I wanted to augment that tutorial with some additional information about URI routing, which I think is one of the great features of the framework.  You see typically your UriMapper might have a 1:1 mapping and look something like this (note in my sample here I'm putting this in App.xaml, but the model may change in the future of where you can/should place UriMapper):

 

   1: <Application xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
   2:              xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
   3:              x:Class="NavigationSample.App"
   4:              xmlns:navcore="clr-namespace:System.Windows.Navigation;assembly=System.Windows.Controls.Navigation"
   5:              >
   6:     <Application.Resources>
   7:         <navcore:UriMapper x:Key="uriMapper">
   8:             <navcore:UriMapping Uri="About-Us" MappedUri="/Views/AboutPage.xaml" />
   9:         </navcore:UriMapper>
  10:     </Application.Resources>
  11: </Application>

 

But what if you still wanted to provide friendlier routes, obfuscate the physical location of the view, but handle the default scenario?  You can as long as you follow your own naming conventions.  Take for instance if we contain all our pages in a folder called Views in our application.  We could then map our routes like this:

 

   1: ...
   2: <navcore:UriMapper x:Key="uriMapper">
   3:     <navcore:UriMapping Uri="{}{page}" MappedUri="/Views/{page}.xaml" />
   4: </navcore:UriMapper>
   5: ...

 

You could also follow some naming conventions if you wanted to make sure you limited it to only pages or something so you require the view page to be named SomethingPage.xaml and then can have a route like:

 

   1: ...
   2: <navcore:UriMapper x:Key="uriMapper">
   3:     <navcore:UriMapping Uri="{}{page}" MappedUri="/Views/{page}Page.xaml" />
   4: </navcore:UriMapper>
   5: ...

 

The navigation routes are read top down so you can still have explicit (or additional) routes in addition to the default.  So given:

 

   1: ...
   2: <navcore:UriMapper x:Key="uriMapper">
   3:     <navcore:UriMapping Uri="About-Us" MappedUri="/Views/AboutPage.xaml" />
   4:     <navcore:UriMapping Uri="History" MappedUri="/Views/AboutPage.xaml" />
   5:     <navcore:UriMapping Uri="{}{page}" MappedUri="/Views/{page}.xaml" />
   6: </navcore:UriMapper>
   7: ...

 

A request to About-Us, History or About would navigate to /Views/AboutPage.xaml regardless.  This provides you some flexibility and granularity in your implementation and also provides additional SEO points for your content.

 

I really like the UriMapper in the navigation framework and have been lobbying to change the default templates Visual Studio spits out to use the UriMapper by default.  It provides you with a cleaner (and perhaps shorter) URI as well as obfuscates your "code" from your URI logic.  Be sure to check out the video if you aren't familiar with the framework at all.

 

In fact in Silverlight 3,  a new project template is supported , which by default has provison for SL3 Navigation.

 

cid:image001.png@01CABF9A.103E2F20

 

Hope this helps.

 

Thanks & Regards,

Arun Manglick

Monday, March 8, 2010

First Prize - Fancy Dress Competition – Community Helper

Hi,

 

Yesterday (08th Mar 2010) my prince came first in the 'Fancy Dress Competition – Community Helper' in class Nursery – Carnation.

He dresssed as a 'Postman'. My sincenre thanks to the Challenger Nursery School for taking such initiatives.

 

Regards,

Arun Manglick