background preloader


Facebook Twitter

MVC Framework (Part 1) 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.

MVC Framework (Part 1)

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. Since then I've been answering a lot of questions from people eager to learn more about it. Given the level of interest I thought it might make sense to put together a few blog posts that describe how to use it in more detail. This first post is one of several I'll be doing in the weeks ahead. A Simple E-Commerce Storefront Application I'm going to use a simple e-commerce store application to help illustrate how the ASP.NET MVC Framework works.

Creating A New ASP.NET MVC Application /Controllers /Models /Views Summary. ASP.NET MVC Tip #48 – Disable Request Validation. By default, the ASP.NET MVC framework prevents you from submitting form data that contains potentially malicious content.

ASP.NET MVC Tip #48 – Disable Request Validation

This feature is called request validation. For example, submitting the following text in an HTML input field causes the ASP.NET MVC framework to throw an exception (Figure 1): <script>Alert(‘I am evil!’) ;</script> Figure 1 – An evil form post This is a good feature. There are situations, however, when it is perfectly legitimate to want people to submit text that contains HTML markup to a website. Unlike a Web Forms application, you cannot disable request validation by using the <%@ Page ValidateRequest=”false” %> directive. You apply the [ValidateInput] attribute to the controller action that accepts the form input. // // POST: /Home/Create [ValidateInput(false)] [AcceptVerbs(HttpVerbs.Post)] public ActionResult Create([Bind(Exclude="Id")]Product productToCreate) { if (!

MVC. Aspnetmvc-nerdinner_v1.pdf (application/pdf Object) MVC Framework (Part 3): Passing ViewData from Controllers to Views. The last few weeks I have been working on a series of blog posts that cover the new ASP.NET MVC Framework we are working on.

MVC Framework (Part 3): Passing ViewData from Controllers to Views

The ASP.NET MVC Framework is an optional approach you can use to structure your ASP.NET web applications to have a clear separation of concerns, and make it easier to unit test your code and support a TDD workflow. The first post in this series built a simple e-commerce product listing/browsing site. It covered the high-level concepts behind MVC, and demonstrated how to create a new ASP.NET MVC project from scratch to implement and test this e-commerce product listing functionality. The second post in this series drilled deep into the URL routing architecture of the ASP.NET MVC framework, and discussed both how it worked as well as how you can handle more advanced URL routing scenarios with it.

Quick Recap from Part 1 In Part 1 of this series, we created an e-commerce site that implemented basic product listing/browsing support. A Simple Product Listing Scenario.