Click here to Skip to main content
15,892,161 members
Articles / Web Development / ASP.NET

URL rewriting using ASP.NET routing

Rate me:
Please Sign up or sign in to vote.
4.83/5 (23 votes)
7 Jul 2009CPOL2 min read 135.6K   6.4K   70  
MVC style search engine friendly URLs using ASP.NET routing, which comes as an enhancement in SP1 of ASP.NET 3.5.
#pragma warning disable 1591
//------------------------------------------------------------------------------
// <auto-generated>
//     This code was generated by a tool.
//     Runtime Version:2.0.50727.3082
//
//     Changes to this file may cause incorrect behavior and will be lost if
//     the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.Linq;
using System.Data.Linq.Mapping;
using System.Linq;
using System.Linq.Expressions;
using System.Reflection;
using System.Web;



[System.Data.Linq.Mapping.DatabaseAttribute(Name="userdb")]
public partial class DataClassesDataContext : System.Data.Linq.DataContext
{
	
	private static System.Data.Linq.Mapping.MappingSource mappingSource = new AttributeMappingSource();
	
  #region Extensibility Method Definitions
  partial void OnCreated();
  partial void InsertUser(User instance);
  partial void UpdateUser(User instance);
  partial void DeleteUser(User instance);
  #endregion
	
	public DataClassesDataContext() : 
			base(global::System.Configuration.ConfigurationManager.ConnectionStrings["userdbConnectionString"].ConnectionString, mappingSource)
	{
		OnCreated();
	}
	
	public DataClassesDataContext(string connection) : 
			base(connection, mappingSource)
	{
		OnCreated();
	}
	
	public DataClassesDataContext(System.Data.IDbConnection connection) : 
			base(connection, mappingSource)
	{
		OnCreated();
	}
	
	public DataClassesDataContext(string connection, System.Data.Linq.Mapping.MappingSource mappingSource) : 
			base(connection, mappingSource)
	{
		OnCreated();
	}
	
	public DataClassesDataContext(System.Data.IDbConnection connection, System.Data.Linq.Mapping.MappingSource mappingSource) : 
			base(connection, mappingSource)
	{
		OnCreated();
	}
	
	public System.Data.Linq.Table<User> Users
	{
		get
		{
			return this.GetTable<User>();
		}
	}
}

[Table(Name="dbo.users")]
public partial class User : INotifyPropertyChanging, INotifyPropertyChanged
{
    
	private static PropertyChangingEventArgs emptyChangingEventArgs = new PropertyChangingEventArgs(String.Empty);
	
	private long _Id;
	
	private string _Name;
	
	private string _UniqueName;
	
	private string _Summary;
	
    #region Extensibility Method Definitions
    partial void OnLoaded();
    partial void OnValidate(System.Data.Linq.ChangeAction action);
    partial void OnCreated();
    partial void OnIdChanging(long value);
    partial void OnIdChanged();
    partial void OnNameChanging(string value);
    partial void OnNameChanged();
    partial void OnUniqueNameChanging(string value);
    partial void OnUniqueNameChanged();
    partial void OnSummaryChanging(string value);
    partial void OnSummaryChanged();
    #endregion
	
	public User()
	{
		OnCreated();
	}
	
	[Column(Name="id", Storage="_Id", AutoSync=AutoSync.OnInsert, DbType="BigInt NOT NULL IDENTITY", IsPrimaryKey=true, IsDbGenerated=true)]
	public long Id
	{
		get
		{
			return this._Id;
		}
		set
		{
			if ((this._Id != value))
			{
				this.OnIdChanging(value);
				this.SendPropertyChanging();
				this._Id = value;
				this.SendPropertyChanged("Id");
				this.OnIdChanged();
			}
		}
	}
	
	[Column(Name="name", Storage="_Name", DbType="VarChar(150)")]
	public string Name
	{
		get
		{
			return this._Name;
		}
		set
		{
			if ((this._Name != value))
			{
				this.OnNameChanging(value);
				this.SendPropertyChanging();
				this._Name = value;
				this.SendPropertyChanged("Name");
				this.OnNameChanged();
			}
		}
	}
	
	[Column(Name="unique_name", Storage="_UniqueName", DbType="VarChar(50) NOT NULL", CanBeNull=false)]
	public string UniqueName
	{
		get
		{
			return this._UniqueName;
		}
		set
		{
			if ((this._UniqueName != value))
			{
				this.OnUniqueNameChanging(value);
				this.SendPropertyChanging();
				this._UniqueName = value;
				this.SendPropertyChanged("UniqueName");
				this.OnUniqueNameChanged();
			}
		}
	}
	
	[Column(Name="summary", Storage="_Summary", DbType="Text", UpdateCheck=UpdateCheck.Never)]
	public string Summary
	{
		get
		{
			return this._Summary;
		}
		set
		{
			if ((this._Summary != value))
			{
				this.OnSummaryChanging(value);
				this.SendPropertyChanging();
				this._Summary = value;
				this.SendPropertyChanged("Summary");
				this.OnSummaryChanged();
			}
		}
	}
	
	public event PropertyChangingEventHandler PropertyChanging;
	
	public event PropertyChangedEventHandler PropertyChanged;
	
	protected virtual void SendPropertyChanging()
	{
		if ((this.PropertyChanging != null))
		{
			this.PropertyChanging(this, emptyChangingEventArgs);
		}
	}
	
	protected virtual void SendPropertyChanged(String propertyName)
	{
		if ((this.PropertyChanged != null))
		{
			this.PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
		}
	}

    
}
#pragma warning restore 1591

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Apdynamics Inc
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions