asp.net-mvc-2

VS2008 + MVC2 RC + L2S or VS10Beta2 + MVC2 Preview 2 + EFv4

I'm starting a new project which must have a working prototype within 10 days. The project should be cutting edge and I'd love to use latest tech, especially EFv4. But, also I like new MVC2 features like ForEdit and easier validation implementation (for Areas I don't care). MVC2 RC is out for VS2008 and works on VS10Beta 2 too, but "too...

TextBoxFor rendering to HTML with prefix on the ID attribute

I have an ASPNET MVC 2 project. When I use <%= Html.TextBoxFor(model => model.Login) %> the TexBoxFor will render as <input id="Login" name="Login" type="text" value="" /> Field in the model is [Required(ErrorMessage = "")] [DisplayName("Login")] public string Login { get; set; } Can I made id and name attribute with some pref...

ASP.NET MVC 2 RC model binding with NHibernate and dropdown lists

I have problem with model binding in my ASP.NET MVC 2 RC application that uses NHibernate for data access. We are trying to build the application in a Ruby on Rails way and have a very simple architecture where the domain entities are used all the way from the database to the view. The application has a couple of domain entities which c...

Asp.net MVC and Web Application Administrative Tasks

I am little bit confuse with Asp.net MVC Area. When we talk about WebForms we say, for Administrative tasks, you must have an Admin folder to separate the admin task. In MVC how i will treat my Admin tasks? I will go for Admin Area or Admin Controllers, Because if i will write controller for Admin tasks, each and every task will be w...

Why are Redirect Results not allowed in Child Actions in Asp.net MVC 2

I have some partial actions that I render with the Asp.Net Futures RenderAction method. Some of these perform redirects after the forms in them have been processed. Now that I upgraded to Asp.Net MVC 2 RC it gives me an error "Child actions are not allowed to perform redirect actions". I checked out the source code and I found the line...

Redirect from one Area's action to a action in the "root"-area?

I use the latest version of ASP.Net MVC 2 RC. My question is, how do I redirect from one action that's in the "Blog"-area to the index-action in the home-controller that exists in the "root" of my application (no area)? I tried: return RedirectToAction("index", "home"); but this redirects to /Blog/home, where Blog is the name of my ...

Error building ASP MVC solution with Team City

Im testing out the new MVC2 framework, and there I also have tried out the new areas functionality. Im following this example: Walkthrough: Creating an ASP.NET MVC Areas Application Using Multiple Projects Everything builds and runs okay locally, but when I try to commit to my repository and the use the build automation engine Team Ci...

Asp.net MVC 2, spark engine and strongly Typed Html Helpers

Will I get the advantage of the new Strongly Typed Html Helpers with asp.net MVC 2 if were to use the spark engine for rendering? ...

Asp.net Mvc2 - DisplayFor need iteration-like context

In my app I have a criteria builder section that's built using jquery and is pitched back to the controller in a form post and picked up as IList by the model binder as suggested in Phil's post here: http://haacked.com/archive/2008/10/23/model-binding-to-a-list.aspx A really simple way that I'm persisting the criteria across posts is re...

MVC Model Validation Programmatic Registration support

Today (15th Jan 2010) Scott blogged about the ASP.NET MVC2 model-validation http://weblogs.asp.net/scottgu/archive/2010/01/15/asp-net-mvc-2-model-validation.aspx Anyone knows how can someone add validation rules at runtime programmatically ? "Programmatic Registration" is a similar functionality supported by ValidationAspects // regi...

Is there a bug in ASP.Net MVC 2 RC version for UpdateModel()?

I'm trying to implement MVC 2 RC version, the latest release of ASP.Net MVC and it can't do a simple Controller.UpdateModel(object) without throwing this exception: The model of type '[Insert namespace of object being updated here]' could not be updated. InvalidOperationException Here's the stack trace: at System.Web.Mvc.Controller.U...

Best practices concerning view model and model updates with a subset of the fields

By picking MVC for developing our new site, I find myself in the midst of "best practices" being developed around me in apparent real time. Two weeks ago, NerdDinner was my guide but with the development of MVC 2, even it seems outdated. It's an thrilling experience and I feel privileged to be in close contact with intelligent programmer...

Create HtmlHelper instance in Controller

I need to do with HtmlHelper in Controller, so how i create it in Controller (asp.net mvc 2.0)? ...

Multiple projects using ASP.NET MVC areas

How can I setup multiple projects using areas in asp.net mvc 2? ...

Create Generic Controller in custom controllerfactory

I use this code to create my controller: public override IController CreateController(RequestContext requestContext, string controllerName) { try { Type controllerType = null; var baseControllerType = typeof(DashboardController<>); var item = _repository.GetByUrlSegment(requestContext.Rou...

Asp.net Mvc2 LabelFor and DisplayName from prop

Context => ${Html.CheckBoxFor(x => x.Foos[i].Checked)} ${Html.LabelFor(x => x.Foos[i].Checked)} Problem is - i can't provide label text based on Foo.Name. Is there out of the box method of how to modify metadata, passing in lambda x=>x.Name to change it? Is creating another HmtlHelper extension method LabelFor(this htmlhelper, [...

ASP.NET MVC 2 strongly typed htmlhelper, indexes

public class Foo { public bool Checked {get;set;}} View: <viewdata model="Foo[] fooList" /> <for each="var f in fooList"> ${Html.CheckBoxFor(x=>x[fIndex].Checked)} </for> Will output: <input id="Checked" name="Checked" type="checkbox" value="true" /> <input name="Checked" type="hidden" value="false" /> <input id="Checked" name...

Why does MvcHttpHandler is mapped from *.mvc?

By default the web.config file for MVC project have the following element: <handlers> <remove name="MvcHttpHandler"/> <add name="MvcHttpHandler" preCondition="integratedMode" verb="*" path="*.mvc" type="System.Web.Mvc.MvcHttpHandler"/> </handlers> My problem is that my site returns 404.14, after knocking out all the usual ...

ASP.Net MVC 2 File Organization; Views and Controllers

I am part of a development team implementing a large application. There are several layers to the application, and we'd like to make the organization of files as easy to maintain as possible, but also follow best practice. Here is an example of how this is laid out based on MVC convention. UIProject - Controllers - HomeController.cs...

ASP.NET MVC 2 Areas and route priority

Is it possible to set route priority in asp.net mvc 2 using arearegistration? I have a catch all {*pagePath} route which I want to set the lowest priority on. ...