Contents tagged with MVC Framework
-
What role does the User Control has in the ASP.Net MVC?
Several developers have asked me about the use of User Controls within the ASP.Net MVC, so I decided to write down what I think about it.
-
ASP.Net MVC Framework - How do I design my apps with the MVC pattern and +P
When I'm playing around with the ASP.NET MVC Framework I have created several prototype applications with different solutions to solve some "problems." In this post I will write down how I combine a Presentation Model (When I talk about Presentation Model in this post, I refer to a model which purpose is only to define a model for presentation purpose) with the MVC, it's what the P in MVC+P stands for.
When I build apps today I use Domain Driven Design and I use the MVC pattern in some of my web based applications. As many of you know the M in MVC stands for the Model and contains our entities, business logic can data access components. Often when I build my apps with the ASP.Net MVC Framework (still only use in as a prototype because the framework is under development) I create my own custom Controller Factory to support Dependency Injection (DI). For example I use constructor injection or setter injection to inject my Repositories or manual injection of Mock objects during test. I use Spring.Net as my DI framework because it’s the framework I like the most. -
ASP.Net MVC Framework pre- Preview 3 - A Step by Step guide to create a simple web app.
Yesterday I posted a step by step guide by using the Preview 2 of the ASP.Net MVC Framework, the following is an updated version that targets the pre-release of the Preview 3 version of the ASP.Net MVC Framework.
-
ASP.Net MVC Framework Preview 2 - A step by step guide to create a simple Web Application
UPDATE: When I cerated a new post on my blog about the pre-release of Preview 3, I replaced this one with the new post. I did my best to recover the content. Sorry!
-
ASP.Net MVC Framework 2 - The Binding helper class (UI-mapper)
-
ASP.Net MVC Framework 2 - Interception and creating a Role Action Filter
With the ASP.Net MVC Framework Preview 2, we can use Action Filters. An Action Filter can be used to intercept actions before and after an Action method of a Controller is executed. By using Action Filters you can for example add code that will check if a user has the right permission to access a action method, or you can use it to log messaged before and action is executed, and also after. An Action Filter is easy to apply to a Controller or its Action method. Just add the ActionFilter as an attribute to the class or specific method of a Controller.
-
ASP.Net MVC Framework 2 - Define Routes in Web.config
Something I like with ASP.Net MVC Framework Preview 2 is the RouteValueDictionary used by the Route class’s Defaults, Constraints and DataTokens property, before they use an anonymous type. Because the properties are now a specific type it’s much easier to define the routes in web.config. Before it was quite easy but some reflection was needed. I have now created a ConfigSection and a helper method to easily register routes which can be defined in the web.config for the Preview 2 version of the ASP.Net MVC Framework. I decided to use the following XML structure to define routes in web.config:
-
ASP.Net MVC Framework - Using Forms Authentication
NOTE: THIS Post was written when ASP.NET MVC Framework was in a early Preview stage.
-
ASP.Net MVC Framework - Assign a ViewFactory to a Controller
I have seen several posts about how to assign a ViewFactory to a Controller, most of the case the code looks like this:
public class HomeController : Controller
{
public HomeController()
{
this.ViewFactory = new MyViewFactory();
}
} -
MVC - Expression Language and custom tags
I have seen several developers that want and have no problem by using server-side code blocks in a View when they are working with the MVC pattern. But I think the server-side code block should be used only in some advanced and special occasions and instead use an Expression Language. By using a lot of server-side code block can make the View messy and the solution can be difficult to implement, form the perspective of code maintainability and extensibility. If we instead use tags similar to HTML/XML we can make the code blend into HTML in a nice way.
Take a look at the following code:
<% if (ViewData != null && ViewData.HasError) {%>
...
<% } %>