asp.net-mvc-2

Best ASP.NET MVC book?

I'm going to be starting a new project with VS2008/ASP.NET, and I would like to use MVC. What is the best MVC book out there? (Are there any good ones?) Edit: I threw in the asp.net-mvc-2 tag so we could possibly get some updated answers. ...

Passing Controller a FormCollection and an IList<T>

I have a form which contains a whole heap of data entry fields that will be completed by the user including some elements where the user can dictate how many of the same items they will enter. This is as is being used in Phil Haack's blog entry Model Binding To A List. I am successfully using JQuery to create the extra form elements, co...

ASP.NET MVC 2.0 overview information?

I have heard that Microsoft is developing a MVC 2.0 platform for Visual Studio 2010. Does anyone have a good source of information about the upcoming project? Specifically, an overview of the changes and new features? ...

ASP.NET MVC 2 Preview 1 - what is the best way to implement areas?

In the latest release of ASP.NET MVC 2 they have launched the concept of areas as supported by MS. However to perform this areas concept one has to create multiple separate projects. One project per area. In ASP.NET MVC 1 there were many other ways out there to support areas where you would still be working within the same project. T...

ASP.NET MVC 2 editor template for value types, int

I want to create a MVC 2 editor template for a value type i.e. int , has anyone done this with the preview 1 bits? Many thanks ...

Validation: Model or ViewModel

Where should validation reside when using ViewModels with MVC (MVVM), on the Model or the ViewModel? (Or both or neither)? And why? I bring this up especially in light of V2 of ASP.NET MVC coming out soon. What about complex/custom validation? ...

Form input validation options in ASP.NET MVC 1.0+

A number of questions have been asked on this topic before, but since ASP.NET MVC is moving quite fast I wanted to re-ask the question: What would you recommend for providing form input validation in ASP.NET MVC? Requirements: Server-side checking Client-side (JavaScript) checking Should cover the basics such as mandatory fields, num...

Unit tests on MVC validation

How can I test that my controller action is putting the correct errors in the ModelState when validating an entity, when I'm using DataAnnotation validation in MVC 2 Preview 1? Some code to illustrate. First, the action: [HttpPost] public ActionResult Index(BlogPost b) { if(ModelState.IsValid) { ...

Is it viable to use ASP.NET MVC 2 Preview 1 in a production application?

Hello, I'm not sure if it is viable to use ASP.NET MVC 2 Preview 1 already in a production system? I would like to, because it introduces several much-needed functionalities which are quirky in MVC 1. Unfortunately I didn't find anything about that topic or roadmap information in ScottGu's release post from 7/31. Is MVC2P1 already pre...

Html.LabelFor Specified Text [ASP.NET MVC 2]

Anyone got any idea on how to specify text when using Html.LabelFor(c=>c.MyField). It's just MyField might not be an appropriate name to display on screen, you may want "The Super Fantastic Field" instead, but there doesn't appear to be any overloads. Any ideas? ...

Site navigation for an 'Admin' application in ASP.NET MVC

I've made an Area project for my ASP.NET MVC application called 'Admin'. This will contain all the logic for the Administration section of the site, where the users can add/remove pages, etc. There's a menu at the top, of things the user can manage. (E.g. 'Content', 'Users', etc) For each of these, I'm making a controller ('ContentCon...

ASP.NET-MVC2 Preview 1: Are There Any Breaking Changes?

I was following Steven Sanderson's 'Pro ASP.NET MVC Framework' book. On page 132, in accordance with the author's recommendation, I downloaded the ASP.NET MVC Futures assembly, and added it to my MVC project. Then, without encouragement from the author, I downloaded, installed, and incorporated the ASP.NET MVC2 Preview 1 dlls into my pr...

ASP.NET MVC 2 Preview 1 - Problem compiling StructureMap Controller Factory

I have a project for which I use StructureMap for dependency injection. The project compiles fine as a MVC project but after moving everything to a MVC2 project I am now receiving the following error: Test.Web.Controllers.StructureMapControllerFactory.GetControllerInstance(System.Type)': no suitable method found to override C:\...

ASP.NET MVC 2 Preview 1 - DataAnnotation Validation with complex model object

The ability to let the model handle its own validation has lead me to begin playing with the MVC 2 preview release. So far, I like the simplicity of the validation scheme. However, I have run into a roadblock. This validation style works fine for simple view model objects. For example if I have a model object named car and I'm lookin...

Ways to define an ASP.NET MVC Route

I was wondering if you could show me all the various ways to declare routes in ASP.NET MVC (1 and 2). Please explain each method of defining a route, how it is used, and what case it covers. Here is an example of what I am hoping to collect here: routes.MapRoute("Directors", "Directors/{filter}/{skip}", new { controller = "Dir...

HttpModule with ASP.NET MVC not being called

I am trying to implement a session-per-request pattern in an ASP.NET MVC 2 Preview 1 application, and I've implemented an IHttpModule to help me do this: public class SessionModule : IHttpModule { public void Init(HttpApplication context) { context.Response.Write("Init!"); context.EndRequest += context_EndRequest...

Is it a good idea to put content access logic in a BaseController?

I'm developing an ASP.NET MVC application where the content for any page can be pulled from the database, if it exists, and displayed on the page. This is to make it possible for non-technical persons to edit the content without having to go into the source code (e.g. views) and change things. The way I'm doing this is, each controller...

ASP.NET MVC - Current Action from controller code?

This is very similar to another recent question: http://stackoverflow.com/questions/362514/asp-net-mvc-current-action However, I want to get the name of the current action from within controller code. So within the code of a function that's being called by an Action, I want to get a string of the name of the current Action. Is this p...

Maintaining ViewData between RenderAction calls

I'm rendering a common Log-In form using Html.RenderAction, on every page of my site. If the user enters their details into the text-box and clicks 'Submit', it does a POST to a controller that handles the log in. If they make a mistake, such as entering an invalid email address, it will populate the ModelState with an error message an...

ASP.NET MVC 2 DisplayFor()

I'm looking at the new version of ASP.NET MVC (see here for more details if you haven't seen it already) and I'm having some pretty basic trouble displaying the content of an object. In my control I have an object of type "Person", which I am passing to the view in ViewData.Model. All is well so far, and I can extact the object in the ...