Posts Tagged ‘Framework 3.5’

February 25th, 2008

What I Learned About MVC On Day One

I am really blown back about how fast and easy MVC is to develop with.  I know the guys at Microsoft do a good job with their .NET coding, but I am really impressed by the forethought they put in to MVC.  It builds on top of the standard ASP.NET package, but does it in such a way that makes it lean on top of the already feature-rich (read bloated) ASP.NET Page object.  It really doesn’t feel like I have all that baggage anymore.

These are the following links that got me started designing my very first MVC application.

Keep a watch on my blog about for my posts about Unit Testing MVC and using Validators in the Routing table.  Also I am currently exploring if it is possible for my URL Rewriter and Reverse Proxy to be used in combination with the MVC Routing table.  I will keep you informed.

Tags: , , , , ,

Posted in ASP.NET, C# | kick it on DotNetKicks.com | Bookmark | View blog reactions | 8 Comments »

December 7th, 2007

SEO and C# Extention Methods

I previously talked about the importance of using the correct kind of redirect to optimize your website for search engines in an article titled. World Of HTTP/1.1 Status Codes. I just recently decided to create a C# Utility class to help me in this endeavor and to extended the far from complete HttpResponse.Redirect method. I am using a new C# 3.0 language extension called Extension Methods. Basically what the extension method does is, it allows you to, add methods to types that you don’t have the ability to modify, in my case the HttpResponse class.

I have created the following code to give me better control over my redirects in the HttpResponse class.

public static void Redirect(this HttpResponse response, int type, string url)
{
	response.Clear();

	switch (type)
	{
		case 301:
			response.StatusCode = (int)HttpStatusCode.MovedPermanently;
			response.StatusDescription = "Moved Permanently";
			break;

		case 302:
			response.StatusCode = (int)HttpStatusCode.Found;
			response.StatusDescription = "Found";
			break;

		case 303:
			response.StatusCode = (int)HttpStatusCode.SeeOther;
			response.StatusDescription = "See Other";
			break;

		case 304:
			response.StatusCode = (int)HttpStatusCode.NotModified;
			response.StatusDescription = "Not Modified";
			break;

		case 307:
			response.StatusCode = (int)HttpStatusCode.TemporaryRedirect;
			response.StatusDescription = "Temporary Redirect";
			break;

		default:
			goto case 302;
	}

	response.RedirectLocation = url;

	response.ContentType = "text/html";
	response.Write("<html><head><title>Object Moved</title></head><body>");
	response.Write("<h2>Object moved to <a href=\"" + HttpUtility.HtmlAttributeEncode(url) + "\">here</a>.</h2>");
	response.Write("</body></html>");

	response.End();
}

So now in your code you don’t have to jump through hoops to chance the StatusCode, StatusDescription, RedirectLocation, and ContentType, just so you can respond with a 301 Redirect instead of a 302 Redirect (the default for HttpResponse.Redirect and the most dangerous of the redirects from an SEO point of view). All that you need to have access to is the Response property from your Page or Context and you are good to go.

Response.Redirect(301, "http://www.coderjournal.com");

So that is all you need to do to give your self better control over your redirects in .NET. You can also use this same C# 3.0 Extension Methods for any object that you need to add a custom method on to.

Tags: ,

Posted in C#, Programming, SEO | kick it on DotNetKicks.com | Bookmark | View blog reactions | 2 Comments »

November 19th, 2007

Visual Studio 2008 and .NET 3.5 Released

Scott Guthrie has announced that Visual Studio 2008 and .NET 3.5 are now available for download and provides a tour of some of the new features.

  • If you are a MSDN subscriber, you can download your copy from the MSDN subscription site (note: some of the builds are just finishing being uploaded now - so check back later during the day if you don’t see it yet).
  • If you are a non-MSDN subscriber, you can download a 90-day free trial edition of Visual Studio 2008 Team Suite here. A 90-day trial edition of Visual Studio 2008 Professional (which will be a slightly smaller download) will be available next week. A 90-day free trial edition of Team Foundation Server can also be downloaded here.
  • If you want to use the free Visual Studio 2008 Express editions (which are much smaller and totally free), you can download them here.
  • If you want to just install the .NET Framework 3.5 runtime, you can download it here.

Tags: , , , , , ,

Posted in ASP.NET, C#, Programming | kick it on DotNetKicks.com | Bookmark | View blog reactions | No Comments »

July 9th, 2007

Evolution Of LINQ And Its Impact C# 3.0

One of the things I love to learn about is the history of how things come to be. Specifically my interests have always been in the evolutions of religion and the tech world (yeah I know pretty much polar opposites, but that is what I like to learn about). I came across an interesting article in my MSDN subscription that talked about how language features of C# 3.0 came to be. The features I am talking about are:

  • Lambda Expressions
  • Extension Methods
  • Anonymous Types
  • Implicitly Typed Local Variables
  • Object Initializers
  • Query Expressions
  • LINQ

All these features were made possible because of they wanted to add a feature that let you query collections much like how you query SQL (LINQ) and the strong convictions of the C# language maintainers to not implement hacked together solutions. Much of the same convictions that I try to promote on this blog, and because of these convictions C# developers got some very nice features out of the language.

If you have not heard of LINQ before, this is the basic C# language construct (notice the similarities to SQL):

var overdrawnQuery = from account in db.Accounts
                     where account.Balance < 0
                     select new { account.Name, account.Address };

This article, The Evolution Of LINQ And Its Impact On The Design Of C#, is well worth the read and I recommend it to anybody that wants to learn more about C# 3.0 or is just interested in how good coding practices can have great impact on projects.

Tags: , , ,

Posted in C#, Programming, SQL | kick it on DotNetKicks.com | Bookmark | View blog reactions | No Comments »