Jack @ ASP.NET

As a software engineer, I focus on .NET, especially asp.net, C#, WCF and so on, and I am also very interested in Search Engine Optimization.

Entries for December, 2009

ASP.NET MVC 2 and Visual Studio 2010

Unfortunately, because Visual Studio 2010 Beta 2 and ASP.NET MVC 2 Beta share components which are currently not in sync, running ASP.NET MVC 2 Beta on VS10 Beta 2 is not supported. Regarding Visual Studio 2010 and .NET 4 support, that is unfortunately not a feasible option. The most recent public release of VS2010 and .NET 4 is Beta 2. However, our internal builds of MVC 2 for VS2010 and .NET 4 depend on features that were available only after Beta 2. In other words, if we released what we have right now for VS2010 and .NET 4 then it wouldn’t even run.

The good news is that the Visual Studio 2010 Release Candidate will include a newer version of ASP.NET MVC 2. 

Highlights

As you might expect from a release candidate, most of the work focused on bug fixes and improvements to existing features. We also spent a lot of time on performance profiling and optimization.

Much of the focus on this release was in the client validation scripts. For example, the validation script was moved into its own file and can be included at the top or bottom of the page. Client validation also now supports globalization.

The other change related to validation is that the ValidationSummary now supports overloads where only model-level errors are displayed. This is useful if you are displaying validation messages inline next to each form field. Previously, these messages would be duplicated in the validation summary. With these new changes, you can have the summary display an overall validation message (ex. “There were errors in your form submission”) as well as a list of validation messages which don’t apply to a specific field.

What’s Next?

RTM of course! The RTM release of ASP.NET MVC will be included in the RTM release of Visual Studio 2010, which is slated for some time in March. The VS2008 version of ASP.NET MVC 2 might release earlier than that. We’re still working out those details.

IIS Search Engine Optimization (SEO) Toolkit

The IIS Search Engine Optimization (SEO) Toolkit is an IIS7 extension that helps identify search engine and user experience optimizations for Web sites. The following features are included:
Site Intelligence

  • Reporting and error identification for broken/invalid links, duplicate content, tag validation, etc.
  • Visibility into user routes, referring pages and other patterns
  • Drilldown into page resource usage and load time

Search Relevance

  • Best practice rules for optimizing URL structure for search engines
  • Extensibility model to enable integration for keyword acquisition
  • Automatic generation of search engine support files like sitemaps and robots.txt

Key Features including

  • Improve the volume and quality of traffic to your Web site from search engines
  • Control how search engines access and display Web content
  • Inform search engines about locations that are available for indexing
  • Site Analysis Features
  • Robots Exclusion Features
  • Sitemap and Sitemap Index Features

 

Instructions

You will need to run the installation package as an administrator. This can be accomplished by one of the following methods:

  • Logging in to your server as an administrator account and then double-clicking on the MSI file.
  • Logging on using an account with administrator privileges and opening a command-prompt by right-clicking the Command Prompt menu item that is located in the Accessories menu for Windows programs and selecting "Run as administrator", then typing one of the commands listed below:
    msiexec /I IISSEO_x86.msi
    msiexec /I IISSEO_x64.msi

It takes less than 5 minutes to download and run the SEO Toolkit Analyzer against your web-site.  You simply point the tool at the top-level URL of your web-site, and then it will automatically crawl your site like a search engine would – following each link, reviewing the HTML on each page, and generating a human friendly report of every SEO or content violation it finds on the site – along with suggestions on how to fix each of them.

If you haven’t downloaded the SEO Toolkit and used it to analyzer your web-site yet, then spend 10 minutes now and give it a try.  You’ll find it provides a really easy, automated way to quickly find and identify SEO issues you have on your web-site – along with suggestions on how to fix them.  Fixing them will increase the traffic and visitors to your web-site.

Silverlight 4 demos available now!

Demos are available now, You can download the keynote demos at http://www.silverlight.net/community/samples/silverlight-4-beta/ (source code + VS project file included with each sample).

Keynote Demos

PhotoBooth Application

The PhotoBooth application demonstrates some of the fun things you can do with the new WebCam and Microphone support in Silverlight 4.  It allows you to record videos and take photos within the browser – and then optionally apply effects to them (for example: the bulge effect below).  For kicks you can publish a photo of any of the pictures to Twitter :-)

image

BarCode Scanner

The BarCode Scanner application also uses the new WebCam support in Silverlight 4. It allows you to scan an ISBN barcode from the back of a book, and will then use Amazon web-services to look up details about the book online:

image

Rich Notepad

The rich notepad application shows off some of the new text editing features in Silverlight 4.  It allows you to edit rich text within the browser, supports Bidi text (including Arabic and Hebrew), supports both left-to-right and right-to-left control layout (RTL is show below – notice how the scroll-bar is on the left hand side of the screen), supports programmatic copy/paste to the system clipboard, custom right-click context menus, printing, and drag/drop of files from the desktop into the browser to edit:

image

HTML Hosting

The HTML Hosting application shows off using the new Silverlight 4 webbrowser control in an out of browser application (note: you must run the application out of the browser for it to work).  It allows you to use the control both interactively (meaning you can click the HTML within it and run it like an application).  It also allows you to use the hosted HTML as a brush that you can apply to other Silverlight controls. For fun you can click the MSDN.com tab below and you’ll get rick-rolled to YouTube.  You can still use the HTML as a brush and carve it up into a jigsaw – even though the video is still playing (using Flash hosted within the HTML):

image

.NET Development for the iPhone

Until recently your only choice for developing applications for Apple’s iPhone was to jump into the Apple development ecosystem. This means being willing to write Objective-C code in the XCode IDE. For many developers, learning Objective-C was seen as a huge barrier-to-entry. This is especially true for many .NET developers whom have never had to worry about memory management, pointers, and other C language responsibilities that they are unfamiliar with.

All this has changed with the introduction the MonoTouch framework, a part of Novell’s Mono Project. The Mono Project is an open-source implementation of Microsoft .NET Platform. It allows you to run .NET applications on nearly any platform, including Apple, FreeBSD, Linux, Unix, and others. MonoTouch, which is a new part of the Mono Project, allows you to write applications using C# with .NET platform that run on the iPhone.

The intent of this article is to provide a solid introduction to the MonoTouch platform, where to find all the necessary pieces, the limitations of it, and how to build a basic application.

How does it Work?

When building MonoTouch applications, most of the non-UI .NET 3.5 stack is either already available, or is in the roadmap to be included. This allows you to write applications using many of the .NET Framework Technologies that you’re already familiar with, including Windows Communication Framework (WCF), Workflow Foundation (WF), etc. It also includes nearly all of the Base Class Library (BCL) including things like Garbage Collection, Threading, Math Functions, System.Net, Cryptography, etc. For a list of available standard .NET assemblies see http://monotouch.net/Documentation/Assemblies. This is accomplished through a MonoTouch-specific set of base .NET libraries, similarly to how Silverlight and Moonlight work.

This means that you can compile standard .NET 3.5 code libraries using the MonoTouch core assemblies and use them in your application. So if, for example, you have a specialized library that does advanced math functions for engineering problems that you use for other applications, you can simply include the code library in your MonoTouch solution, and reference it. When you build your solution, it will compile it using the MonoTouch libraries, and it will then be available in your application.

MonoTouch also includes wrappers to the native iPhone APIs such as Location (GPS), the accelerometer, address book, etc. It also gives you the ability to bind to native Objective-C libraries that are not wrapped, so you can interop directly with existing Objective-C code.

How do I Distribute My Apps?

MonoTouch applications are distributed the exact same way that traditional iPhone applications are distributed, either via the Apple App Store, or Enterprise deployment.

The App Store is an online repository that allows users to pay for applications (if they’re not free), and download them. It is available from within iTunes, or directly from the iPhone itself. In order to get a license to distribute via the App Store, you must register with Apple, and pay $99/year.

Enterprise deployment is for those wishing to develop internal applications for a company, and distribute them to employees, etc., without listing them with the App Store.

What is the Licensing Model?

Unlike Mono, MonoTouch is not open source and is a commercial product. That means if you want to do anything useful with it you have to purchase a license. MonoTouch comes in three flavors and prices:

  • Professional ($399) – A single personal developer license that allows you to develop applications and distribute them via the Apple App-Store.
  • Enterprise ($999) – A single corporate developer license that allows you to develop applications and distribute via the App-store, or enterprise deployment.
  • Enterprise, 5 Seat ($3,999) – The same as the Enterprise license, but includes 5 seats.

All three options include a year of free updates.

There is also an evaluation edition that allows you deploy to the simulator only. For the purposes of this introduction, that is all we’ll need.

asp.net mvc best practices

The ASP.NET  MVC  is becoming more and more popular each day.  As the application grows in size so does the maintenance nightmare.  Following are some of the better practices, that if followed, may help maintain our application and also provides a means of scalability as the demand increases.  Feel free to add/update practices as required.

  1. Isolate Controllers
    Isolate the controllers from dependences on HttpContext, data access classes, configuration, logging etc.  Isolation could be achieved by creating wrapper classes and using an IOC container for passing in these dependencies
  2. IoC Container
    Use an IoC container to manage all external dependencies  The following are some of the wellknown containers/framework.
    1. Ninject
    2. Autofac
    3. StructureMap
    4. Unity Block

  3. No "magic strings"m
    Never use magic string in your code.   More to come on this.
  4. Create a ViewModel for each view
    Create a specialized ViewModel for each view.  The role of ViewModel should only be databinding.  It should not contain any presentation logic.
  5. HtmlHelper
    For generating view html use HtmlHelper.  If  the current HtmlHelper is not sufficient extend it using extension methods.  This will keep the design in check.
  6. Action Methods
    Decorate your action methods with appropriate verbs like Get or Post as applicable.
  7. Caching
    Decorate your most used action methods with OutputCache attribute.

  8. Controller and Domain logic
    Try to keep away domain logic from controller.  Controller should only be responsible for
    1. Input validation and sanitization.
    2. Get view related data from the model.
    3. Return the appropriate view or redirect to another appropriate action method.
  9. Use PRG pattern for data modification
    PRG stands for Post-Redirect-Get to avoid the classic browser warning when refreshing a page after post.  Whenever you make a POST request, once the request complets do a redirect so that a GET request is fired.  In this way when the user refresh the page, the last GET request will be executed rather than the POST thereby avoiding unnecessary usability issue.

  10. Routing
    Design your routes carefully.  The classic route debugger comes to rescue http://haacked.com/archive/2008/03/13/url-routing-debugger.aspx

Top 10 Free Ways to Increase Your Alexa Ranking

alexa-logo Alexa Rank is a ranking system which bases on the level of traffic that each site receives from the number of people who visit it. So the more the number of traffic you get from your visitor, the more you’ll rank well in Alexa. How you can check your site rank in alexa is simply go to Alexa home page site and search for your own site.

In order to increase your Alexa ranking you must be proactive in your strategies and plan your steps carefully to succeed. With the right Alexa ranking you can demand higher prices from current advertisers and attract new advertisers just the same. If you want to increase your Alexa ranking, there are a few things you can do right now to get there. Remember in order to move up in your alexa rank, you have to bump someone out. You are competing for someone else’s ranking and you better be willing to do what it takes to achieve a higher ranking.

  1. The most basic step is install the Alexa toolbar or Firefox?s SearchStatus extension. Then you can set your blog as your homepage.
  2. Put up an Alexa rank widget on your homepage. Maybe it?s a little annoying but trust me this step is very important. I?ve doing this, and in just couple days my Alexa Rank get raised for about 30%.
  3. Call your friends or your family, ask them to review and rate your Alexa website profile.
  4. Make a post about Alexa. It could be ?100 tips and tricks to increasing your Alexa Rank?, ?Increasing Your Alexa Rank in just 3 Seconds?, etc. Make sure you make an attractive title for your post. Your post will attract many bloggers and webmasters to read. If your post has certain quality, don?t be surprised if you get some juicy backlinks from them.
  5. Make useful articles then promote it on social networking websites. You can also promote it on many webmaster forums, such as Promo Junkie, Digital Point, etc.
  6. Make a cool and useful tool and post it on your blog. It can be a webmaster tools, etc. One of the good examples is TechCrunch’s YouTube Downloader. If your tool very useful, it will make visitors revisit to your website frequently.
  7. Make sure you Dugg or Stumbled your fresh post.
  8. Buy paid-traffic. Did you know that you can buy a thousand traffics at DigitalPoint as cheap as $1? Make sure that you pick a trustful traffic seller. You can also buy advertisements from Google, Adengage, etc. It’s cheap and very useful.
  9. If you want to use a free one, try Alexa auto-surfs. You can search it on Google. Try to use a good one.
  10. The last tips could be a little blackhat, so I don’t recommended it. The trick is by using your social network account on MySpace, Facebook, Friendster, etc. Use attractive pictures and link them to your redirected Alexa URL. Yes, just that simple.

Have a try ~ ~