Building a Simple Blog Engine with ASP.NET MVC and LINQ - Part 2
page 1 of 7
Published: 30 Jan 2008
Abstract
In the second part of the article series about ASP.NET MVC Framework, Keyvan adds controllers to his blogging engine in order to describe how to use controllers in ASP.NET MVC and discusses some details related to controllers. He first discusses the concept of URL routing patterns and then explores the anatomy of a controller class. Finally, he examines how to implement the controllers in his sample blog application.
by Keyvan Nayyeri
Feedback
Average Rating: This article has not yet been rated.
Views (Total / Last 10 Days): 57512/ 405

Introduction

In the first part of this article series about ASP.NET MVC Framework, I gave a short introduction to Model View Controller (MVC) pattern, ASP.NET MVC and the basic structure of the sample blogging engine that I am going to build in this article series and have named it KBlog.

In this second part I am going to cover one of the main three elements in MVC pattern which is controller.

Controller is the most common element of the MVC pattern and is responsible for handling user inputs and executing appropriate codes to load data and display them to the user.

Even though this is not a 100% correct definition, you can consider controller as an intermediate component between the user and view which tries to handle the user inputs and displays the appropriate output to him or her.

Normally, you use some template files to handle different requests in your web applications. It means that you have a page named Post.aspx to handle requests to such a post and the same for other pages. In MVC framework this is different and you use controller classes to handle requests. In other words, you no longer handle user requests with .aspx pages. Instead, you write controller classes that handle requests and pass appropriate data to view pages to be shown to the end users.

But how do controller classes receive requests? To do this, ASP.NET uses an URL routing mechanism that uses routes to route incoming requests to appropriate controller classes. There is a default definition for routing in ASP.NET MVC framework, but you can change it for your own needs as I will do for KBlog in this article series. I will cover routing mechanism in the future parts, but for this part I give a quick overview of the necessary parts.

The other topic that I will cover in this article is the anatomy of controller classes and their structure as well as the action methods and how to pass parameters to action methods in order to route requests to them.


View Entire Article

User Comments

Title: ASP .Net Developer   
Name: ASP .Net Developer
Date: 5/21/2010 7:26:52 AM
Comment:
Hi
Building a Blog engine throw asp .net is cool.
thanks for this.






Community Advice: ASP | SQL | XML | Regular Expressions | Windows


©Copyright 1998-2014 ASPAlliance.com  |  Page Processed at 12/20/2014 10:48:02 AM  AspAlliance Recent Articles RSS Feed
About ASPAlliance | Newsgroups | Advertise | Authors | Email Lists | Feedback | Link To Us | Privacy | Search