ASP.NET MVC Framework External Resources
Two weeks ago I blogged about a new MVC (Model View Controller) framework for ASP.NET that we are going to be supporting as an optional feature soon. It provides a structured model that enforces a clear separation of concerns within applications, and makes it easier to unit test your code and support a TDD workflow. It also helps provide more control over the URLs you publish in your applications, and can optionally provide more control over the HTML that is emitted from them.
Read More
MVC is a framework methodology that divides an application's implementation into three component roles: models, views, and controllers. "Models" in a MVC based application are the components of the application that are responsible for maintaining state. "Views" in a MVC based application are the components responsible for displaying the application's user interface. "Controllers" in a MVC based application are the components responsible for handling end user interaction, manipulating the model, and ultimately choosing a view to render to display UI. In a MVC application the view is only about displaying information - it is the controller that handles and responds to user input and interaction.
Read More
I got a comment on one my previous post “ASP.Net MVC Framework - Exception Handling” that the Rescue style MonoRail is a nice solution to handle Exception thrown within a Controller. In this post I have added something similar to as the Rescue feature of MonoRail (at least I think so ;)) where an attribute can be added to a Controller or on an Action. The attribute can be used to specify which View that should be rendered when an exception is thrown. We can also specify different Views based on different exceptions...
Read More
By implementing my own IrouteHandler I changed the pipeline to support Interceptors before and after an action is invoked...The Interceptors has two methods, PreHandle and PostHandle. The PreHandle returns a value if the process of a request should be stopped or if it should go on with the process of an execution. It’s possible to create a chain of Interceptors. If more than one Interceptor is specified and one of them tells to stop the process, the rest in the chain will not be executed. To specify an Interceptor or a chain of Interceptors I have override the Route class and created my own which has a List of IInterceptors...
Read More
The RouteHandler in this post will replace the IControllerFactory with my own Controller Factory, and also set a default ControllerFactory and a ViewFactory specified in the web.config. This is something the current preview bits of the MVC Framework can’t. It’s quite easy to create our own RouteHandler, we only need to implement the IRouteHandler interface and implement the GetHttpHandler method...
Read More
I will go on by showing how we can create a simple Blog application with the ASP.Net Framework and LINQ to SQL. To create a MVC Web Application we select File -> New Project and select the MVC Web Application template. The Controllers folder should contain the Controllers we will use in our application. In the Models folder we put our model and business objects. In a larger application we will probably use separated class libraries instead of adding the objects to the web application project, this is of course possible. In the Views folder we add the pages (Views). The Views have the responsibility to render the Model. A View is a normal .aspx page, but instead of inheriting the Page object, it inherits the ViewPage object or ViewPage<T>. We can also put MasterPages and Style Sheets into the View folder.
Read More
As many of you already know Microsoft is working on a MVC Framework for ASP.Net. MVC stands for “Model View Controller”. The Model View Controller is a design pattern and the idea is to separate business logic from the View (The View is the page that will display content, for example an .aspx page). The MVC in general maintain a clean separation of concerns, it will be easier to test business logic because it’s separated from the View and the View will not have any knowledge of the underlying model.
Read More
AjaxController is a class I added, and it introduces a new property IsAjaxRequest, which I can use in my action methods to do things like render different views. It also introduces members such as RenderPartial, which can be used to render a portion of the user interface defined within a partial view as opposed to the full page. So here is my updated controller and the updated Add method with the changes and additions in bold.
Read More
Stated goals of the ASP.NET MVC framework are: Enable clean separation of concerns, Be testable by default, Support Inversion of Control (IoC) containers and third-party view engines, Support customization of URLs, Leverage existing ASP.NET features, and Support static and dynamic languages.
Read More
See the presentation of the ASP.NET MVC Framework by Scott Gutrhie at the ALT.NET Conference. What is really impressive is the pluggable and extensible nature of the entire framework: 1) Pluggable View Engines - ASPX, NVelocity, Brail, etc., 2) Pluggable Dependency Injection - Windsor, Spring, etc., 3) Controllers - IController, ControllerBase, Controller, or create your own., and 4) Routing Engine - Use default or create your own engine to map URL's to Controllers.
Read More