ASP.NET 2.0 Resources

Powered by Blogger

ASP.NET 2.0: HOW DO I Video Series

There is a great video series showcasing the new features of ASP.NET 2.0 available free on MSDN. It contains over 2 hours of video focused on the common tasks for developers. I would specially recomend the Tips and Tricks video to everyone. The following free videos are available:

Data Access

This video illustrates how simple it is to create data-driven web sites using Visual Web Developer 2005 Express Edition, ASP.NET 2.0, and SQL Server 2005 Express Edition. Explore how easy it is to create a master-details view with support for filtering, sorting, paging, and editing with no code using the DropDownList, GridView, DetailsView, and ObjectDataSource controls.

Form Building for a "Contact Us" Page

This video introduces a number of the new ASP.NET 2.0 controls for building forms to collect information from the user, validate that information, then send a confirmation e-mail message. Features covered include the Wizard control, Validation controls, and the System.Net.Mail classes for sending e-mail messages.

Master Pages and Site Navigation

Create a Web site with a consistent layout and design across all its pages using ASP.NET 2.0 Master Pages. Become familiar with the enhanced designer support for creating and consuming Master Pages in Visual Web Developer 2005 Express Edition. See the improved Table Editor and Style Builder in action and learn how easy it is to add navigation to a Web site using the new TreeView and SiteMapPath controls.

Membership and Roles

Learn how to secure a Web site using the new Membership and Roles features of ASP.NET 2.0. Topics include user registration, password recovery, and restricting access to content with roles. Get a tour of how the Web Site Administration Tool simplifies user account administration and makes it easy to control content access permissions.

Profiles and Themes

Discover how to create a customizable Web site using Visual Web Developer 2005 Express Edition and ASP.NET 2.0. Learn how to use Profiles to collect per-user configuration information and apply Themes to extend a consistent look-and-feel throughout the Web site.

Create a Full-Featured Customer Login Portal

Get an overview of the major features and improvements introduced with Visual Web Developer 2005 Express Edition and ASP.NET 2.0. Follow along through the creation of a fictitious customer portal to learn about topics including Master Pages, Themes, database access, Membership, Roles, the Web Site Administration Tool, site navigation, and user profiles.

Caching (Part 1) (Part 2)

This video is introducing the new caching features of ASP.NET 2.0. Start with a demonstration of Page Output Caching followed by an overview of the new ASP.NET 2.0 Database Caching support for SQL Server 2000 and SQL Server 2005. Topics include using the aspnet_regsql.exe utility to add SQL caching support to a SQL Server database, creating a SQL cache dependency to eliminate unnecessary connections to the database, enabling table-level caching, and enabling enhanced caching support using SQL Server 2005 Change Notifications. Part two of a two-part series is introducing Partial-Page Output Caching feature of ASP.NET 2.0 followed by an overview of the Cache API, which demonstrates how to efficiently bind a data control to an XML file.

Web Parts and Personalization

This video shows how to use the new Web Parts and Personalization features of ASP.NET 2.0 and the designer support provided by Visual Web Developer 2005 Express Edition to build customizable web pages whose content and layout can be modified by the user. See how Web Parts enable the user to add new content to a page on-the-fly and restructure the page in the browser using drag-and-drop.

Localization

This video is a tour of the web site localization support in Visual Web Developer 2005 Express Edition. Learn how to create culture-aware and locale-specific web content with ASP.NET 2.0 with no additional code. Topics include the new declarative binding syntax, page-level vs. application-level resources, and using the rich resource editor.

Tips and Tricks

This Tips & Tricks video covers many useful techniques for enhancing ASP.NET 2.0 web sites using Visual Web Developer 2005 Express Edition. Topics include encrypting sensitive information stored in web.config, maintaining the browser scroll position across postbacks, posting content to a different page, setting focus on a specific control when a page is loaded, creating a bulleted list of hyperlinks from an XML file, working with the file upload control, simplifying complex URLs using URL remapping, and using the MultiView control to switch between groups of content programmatically.

Read more > Posted on: 2/28/2006 07:01:00 PM

ASP.NET 2.0 RSS Toolkit

This toolkit provides a ton of great support for both consuming and exposing RSS from ASP.NET 2.0 applications, and ships with full source code.

  • RSS Data Source control to consume feeds in ASP.NET applications
    • Works with ASP.NET data bound controls
    • Implements schema to generate columns at design time
    • Supports auto-generation of columns at runtime (via ICustomTypeDescriptor implementation)
  • Caching of downloaded feeds both in-memory and on-disk (persisted across process restarts)
  • Generation of strongly typed classes for RSS feeds (including strongly typed channel, items, image, handler) based on a RSS URL (the toolkit recognizes RSS and RDF feeds) or a file containing RSS definition. Allows programmatically download (and create) RSS channels using strongly-typed classes. The toolkit includes:
    • Stand-alone command line RSS compiler
    • Build provider for .rssdl file (containing the list of feed URLs)
    • Build provider for .rss file (containing RSS XML)
  • Support for generation of RSS feeds in ASP.NET application including:
    • RSS HTTP handler (strongly typed HTTP handlers are generated automatically by the build providers) to generate the feed.
    • RSS Hyper Link control (that can point to RSS HTTP handler) to create RSS links
    • Optional secure encoding of user name into query string to allow generation of personalized feeds
  • Set of classes for programmatic consumption and generation of RSS feed in a late-bound way, without using strongly typed generated classes

The toolkit is packaged as an assembly (DLL) that can be either placed in GAC or in ‘bin’ directory of a web application. It is also usable from client (including WinForms) applications.

The RSS Toolkit automatically includes built-in caching logic so that RSS feed data is cached locally instead of fetched each time it is accessed/used. The RSS Toolkit supports caching this information both in-memory, as well as persistently to disk (for example: to survive worker process restarts or application resets). The benefit of this built-in caching integration is that you can efficiently subscribe and pull RSS data from a variety of remote sources without having to worry about your server blocking on remote network calls all the time. Note that the RSS toolkit by default uses an RSS channel’s TTL setting to control the cache duration semantics for you.

Read more > Posted on: 2/24/2006 08:20:00 AM

Microsoft .NET Pet Shop 4

Microsoft has released new version of .NET Pet Shop application. The .NET Pet Shop application is designed to show the best practices for building enterprise, n-tier .NET 2.0 applications that may need to support a variety of database platforms and deployment scenarios. Full source code is available for download.

This version is designed specifically for ASP.NET 2.0. It takes advantage of it's Master Pages, Membership and user Profiles support. By using this new 2.0 features code base was reduced by 25%. The greatest reduction was made in data tier (almost 36%).

These are the main changes in 4.0 release

  • System.Transactions instead of Serviced Components.
  • Generics for strongly typed collections instead of loosely typed ILists.
  • ASP.NET 2.0 Membership for user authentication and authorization.
  • Custom ASP.NET 2.0 Membership Provider for Oracle 10g.
  • ASP.NET 2.0 Custom Oracle and SQL Server Profile Providers for user state management.
  • Master Pages for consistent look and feel versus ASP.NET Web User Controls.
  • ASP.NET 2.0 Wizard control.
  • Database level cache invalidation using SqlCacheDependency instead of timeout based.
  • Enabling Asynchronous Order Processing built on message queuing.

Read more > Posted on: 2/20/2006 12:18:00 PM

Sql SiteMap provider for ASP.NET 2.0

February issue of MSDN magazine has realy cool article (and source code) about new version of SqlServer SiteMap provider. This version is compatible with Sql Server 7.0, 2000 and also 2005. Sql Server 2005 would be the best choise, because this new SiteMap provider has full support for Sql cache dependencies.

This is also the main difference from previous version. Sitemap automatically reloads, when underlying database changes. Other improvements were also made so this version is more consistent with build-in XmlSiteMapProvider. There is a lot to learn from this provider implementation.

Read more > Posted on: 2/15/2006 08:57:00 AM

URL Rewriting using ASP.NET 2.0 Http Module

This arcticle describes how to write your own Http module for URL rewriting. This solution works only for URL addresses that end with .aspx extension (or any other extension handled by ASP.NET 2.0 framework). It's possible to configure ASP.NET ISAPI filter to handle all request and rewrite all possible URL's, but it won't be covered in this post.

HTTP module is any class that implements IHttpModule interface that contains two simple methods.

public void Init(HttpApplication application) {}
public void Dispose() {)

The first method is called, when the Http Module is initialized. There is a parameter with currenct HttpApplication refference that is passed to this Init method. You can hook to application events using delegate method. First we will hook to Application BeginRequest event, that is fired before request is handled by Http handler (in our case it handled .aspx pages).

   
public void Init(HttpApplication application) {
   application.BeginRequest += new EventHandler(this.Application_BeginRequest);
   application.PreRequestHandlerExecute += 
       new EventHandler(Application_PreRequestHandlerExecute);
}
private void Application_BeginRequest(Object source, EventArgs e)
{
   // rewrite URL to physical path...
   HttpApplication application = (source as HttpApplication);
   if (application != null) {
      HttpContext context = application.Context;
      if (context.Request.RawUrl.IndexOf("rew") > 0)
      {
          context.Items[originalRequestUrlTag] = context.Request.RawUrl;
          context.RewritePath("~/Rewrited.aspx");
      }
   }
}

You will have to substitute Application_BeginRequest method body with your own rewrite logic. In this sample all request that contain string "rew" in URL are rewrited to page ~/Rewrited.aspx. We are also hooking PreRequestHandlerExecute event. This event is called just before control is taken by Http handler. We will check if the page will be handled by System.Web.UI.Page handler and if so, we will hook PagePreInit event where we rewrite back original URL (it's very important otherwise form postback would not work correctly).

private void Application_PreRequestHandlerExecute(object sender, EventArgs e)
{
    HttpApplication application = sender as HttpApplication;
    System.Web.UI.Page page = application.Context.CurrentHandler as System.Web.UI.Page;
    if (page != null)
    {
        page.PreInit += new EventHandler(Application_PagePreInit);
    }
}
static private void Application_PagePreInit(object sender, EventArgs e)
{
    HttpContext context = HttpContext.Current;

    if (context.Items.Contains(originalRequestUrlTag))
    {
        // rewrite back to request Url
        context.RewritePath(context.Items[originalRequestUrlTag] as string);
    }
}

This solution is completely transparent and implemented externally using Http module. The last thig we will have to do is register our new handler in web.config file.

<system.web>
  <httpModules>
    <add name="UrlRewriteModule" type="Core.Rewrite.UrlRewriteModule"/>
  </httpModules>
</system.web>

Read more > Posted on: 2/14/2006 02:42:00 PM

Ten Essential Visual Studio 2005 Tools

There is very usefull article in december 2005 issue of MSDN magazine. It's called Ten Essention Visual studio tools. In the time of it's writing visual studio 2005 was not yet available, but whole arcticle was written with this new version in mind. And which tools are essential for James Avery?

#1 - TestDriven.NET

TestDriven.NET is an essential add-in if you work with unit tests or practice test-driven development. TestDriven.NET was written by Jamie Cansdale and can be downloaded from www.testdriven.net.

#2 - GhostDoc

The only problem with XML documentation is the time it takes to write it you often end up writing similar statements over and over again. The goal of GhostDoc is to automate the tedious parts of writing XML comments by looking at the name of your class or method, as well as any parameters, and making an educated guess as to how the documentation should appear based on recommended naming conventions. GhostDoc was written by Roland Weigelt and can be downloaded from www.roland-weigelt.de/ghostdoc.

#3 - Smart Paster

The Smart Paster add-in provides a number of commands on the right-click menu that let you paste a string from the clipboard into Visual Studio using a certain format. It was written by Alex Papadimoulis and is available from weblogs.asp.net/alex_papadimoulis/category/5341.aspx.

#4 - CodeKeep

Throughout the process of software development, it is common to reuse small snippets of code. Perhaps you reuse an example of how to get an enum value from a string or a starting point on how to implement a certain pattern in your language of choice. CodeKeep was written by Arcware's Dave Donaldson and is available from www.codekeep.net.

#5 - PInvoke.NET

P/Invoke is the process used to access native Win32 API calls within the .NET Framework. The PInvoke.NET wiki and Visual Studio add-in take away a lot of the pain and research time sometimes involved when working with the Win32 API from managed code. The wiki can be accessed at http://www.pinvoke.net/, and the add-in can be downloaded from the Helpful Tools link found in the bottom-left corner of the site.

#6 - VSWindowManager PowerToy

Visual Studio includes the concept of window layouts. You may have noticed that when you start debugging, the windows will automatically go back to the layout they were in the last time you were debugging. This is because Visual Studio includes a normal and a debugging window layout. Wouldn't it be nice if there were additional layouts you could use for when you are coding versus designing? Well, that is exactly what VSWindowManager PowerToy does. VSWindowManager is available from workspaces.gotdotnet.com/vswindowmanager.

#7 - WSContractFirst

If you are developing Web services using Visual Studio you should definitely look into WSContractFirst and contract-first development. WSContractFirst was written by Thinktecture's Christian Weyer and can be downloaded from www.thinktecture.com/Resources/Software/WSContractFirst/default.html.

#8 - VSMouseBindings

Your mouse probably has five buttons, so why are you only using three of them? The VSMouseBindings power toy provides an easy to use interface that lets you assign each of your mouse buttons to a Visual Studio command. VSMouseBindings is available from www.gotdotnet.com/team/ide/#original.

#9 - CopySourceAsHTML

Chances are you may have your own blog by now, or at least have spent some time reading them. Normally, when you try to post a cool code snippet to your blog it ends up being plain old text, which isn't the easiest thing to read. This is where the CopySourceAsHTML add-in comes in to play. This add-in allows you to copy code as HTML, meaning you can easily post it to your blog or Web site and retain the coloring applied through Visual Studio. CopySourceAsHTML was written by Colin Coller and can be downloaded from www.jtleigh.com/CopySourceAsHtml.

#10 - Cache Visualizer

Visual Studio 2005 includes a new debugging feature called visualizers, which can be used to create a human-readable view of data for use during the debugging process. There is no easy way while debugging to get an idea of what is in the cache, how long it will be there, or what it is watching. Brett Johnson saw that gap and wrote Cache Visualizer to examine the ASP.NET cache. You can get Cache Visualizer from Brett's blog at blog.bretts.net.

Read more > Posted on: 2/13/2006 05:05:00 PM

Url Rewriting with ASP.NET 2.0

Today I was researching some options how to rewrite URL's for SEO and accessability in ASP.NET 2.0. I came across some blogposts and finally found this cool site - http://www.urlrewriting.net/. I'm investigating the code right now, but it seems they resolved quite a few commot issues, for example

  • Master page support
  • Correct page postbacks
  • Theeming and skinning

There is sample project and full source code available. Url rewriting is implemented as HTTP module configurable from web.config file. But even this solution has it's own drawbacks caused by pure ASP.NET design. By default it's not possible to rewrite requests for files that are not handled by ASP.NET 2.0 runtime.

Read more > Posted on: 2/13/2006 04:51:00 PM

Visual Studio 2005 Web Application Projects

Some time ago, I was trying to migrate our old Classic ASP based and Visual SourceSafe maintained projects to Visual Studio 2005 Web project with little or no success. This new Visual Studio 2005 Web project works without project files and that turn out to be quite a problem in combination with VSS.

  • I was not able to exclude some files and directories from project and they were checked in to SourceSafe database (that was not desired).

I have found a solution in making my own project template that is similar to C# library project. I had to sacrifice some Visual Studio 2005 Web project features, but at least we were able to develop our existing project with this new Visual Studio version.

But today there is a new option and hope :) Visual Studio 2005 Web Application Project. As said by Scott Guthrie... The Visual Studio 2005 Web Application Project Model is a new web project option for Visual Studio 2005 that provides the same conceptual web project approach as VS 2003 (a project file based structure where all code in the project is compiled into a single assembly) but with all the new features of VS 2005 (refactoring, class diagrams, test development, generics, etc) and ASP.NET 2.0 (master pages, data controls, membership/login, role management, Web Parts, personalization, site navigation, themes, etc).

Read more > Posted on: 2/13/2006 03:46:00 PM

Created dolly