asp.net-mvc-2

Modelmetadata for sorting properties?

Is there any way of setting sort order of my properties with model metadata? ...

How to create ValueProvider for MVC

I want to create a Valueprovider in ASP.Net.MVC 2 Beta. My Value source would be a JSON ...

ASP.NET MVC 2 - Setting values on IValueProvider

I am attempting to upgrade my MVC 1 project to MVC 2 RC. We currently have a custom modelbinder that adds items to the ValueProvider (this worked when it was a dictionary). We then passed this off to the default modelbinder. However, IValueProvider does not have an add method, so this algorithm no longer works. Does anyone know of a way ...

Can you pass a model with RedirectToAction?

I'm using mvc 2 release candidate, and am wondering if there's any way to pass a model to an action using RedirectToAction. For example, I have an edit action which takes an ID, and loads the record from a database, displays the current values in text boxes and lets the user edit and click submit: public ActionResult Edit(int ID) The...

changing view mvc 2 causes problems handing post

I have a controller with the following actions: public ActionResult Create() { return View(new MyModel()); } [HttpPost] public ActionResult Create(MyModel model) { //Update database ... //Pass the current model so we don't have to load it from the database return View("Details", model); } [HttpPost] public ActionRe...

What's the best BDD framework for working with ASP.NET MVC 2 + C# 4?

I just heard about BDD when I watch video of Scott Guthrie in Sweden. One of listener asked question to Scott about How VS2010 and ASP.NET MVC do to support BDD. After that, I search about BDD (Behavior Driven Development) that focus on specification more than unit testing when compares with TDD (Test Driven Development). I found some f...

True SEO urls in asp.net mvc 2

I'm building a simple cms system and would like to have true seo urls with hierarchical levels of pages like http://www.mydomain.com/lorem-ipsum/dolar/sit-amet/. Whats the best approach to successfully implement urls like this? ...

Using jquery in an asp.net mvc 2 editor template

I've created an editor templace in an mvc app, and I want to restrict the input of each text box in the template to only numbers. At render time, the template my be rendered multiple times on the page because the view could have multiple properties that are of type phone number, so the actual IDs of the text boxes will get unique names....

Silverlight 4.0 + MVC 2.0 + WCF RIA Services + EF 4.0 = Load Error

I'm trying to buid a site with the following: VS 2010 (for the updated WCF RIA Services) Silverlight 4.0 (packaged with WCF RIA Services). MVC 2 EF 4.0 I am setting it up so that the public facing pages will be html from MVC, but the administration portion will be a silverlight navigation application using using WCF RIA Services for ...

Changing Model Binder per Controller instead of by type or with attributes?

I'd like to be able to swap model binders out on a per Controller or per ActionMethod basis. AFAIK the only options supported by the framework are to bind a model binder to a specific type. How could I change my model binder per Controller or per ActionMethod in a clean way? ...

ASP.NET MVC and NHibernate associations

Say I have a class, e.g.: public class Person { public virtual int Id { get; set; } public virtual string Name { get; set; } public virtual int SpouseId { get; set; } public virtual Person Spouse { get; set; } } I have included the SpouseId because that is the out-of-the-box way to model bind using (Try)UpdateModel (ba...

Migrating legacy ASP.NET to MVC 2 (RC): HttpApplication events not firing, User principal is null

Problem I am trying to take an existing ASP.NET web application and manually migrate it over to use MVC 2 (I am currently running the RC). I followed several steps (I'll list in a moment) and seemed to have it working, but then I noticed I can't set the AuthorizeAttribute because User is null on the controller. Then I noticed that when ...

MVC2 ViewData Problems

I'm trying to pass a list of a few items to a view via the ViewData to create a drop down list. This shouldn't be too difficult, but I'm new to MVC, so I'm probably missing something obvious. The controller assigns the list to the ViewData: ViewData["ImageLocatons"] = new SelectList(gvr.ImageLocations); and the view tries to render ...

How to use EditorFor inside a foreach

I have a model: public class MyListModel { public int ID {get;set;} public List<User> Users{get;set;} } How do I use the Html.EditorFor method inside a foreach? <%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<MyListModel>" %> <table> <tr> <th></th> ...

Recommended url structure for parent child list in mvc

If I am listing child items of a parent in an asp.net mvc app, is there a best practice to how the url structure should be formed? Example: 1. http://app/parent/&lt;parentID&gt;/children 2. http://app/parent/children/&lt;parentID&gt; I'm personally more inclined to choose option 1, but am wondering if there is a particular way that...

Storing state in asp.net MVC

I'm building an asp.net MVC 2 app. I have a list view which lists items based on a parameter. In the database I have a parent and child table, so my list view lists all the child records for where the parent's id matches the value specified in the parameter. This is my controller and model: public ActionResult List(int ParentID) { ...

How do I make a MVC 2 Json serializable structure with apropriate PK array keys.

I have a table with a Int PK column and a name. I want to load them into an object of some sort and return them using Json() ActionResult in MVC 2. I am having a hard time finding a built-in structure that is supported for serialization that keeps a simple key/value structure in tact. Ultimately I would like to do something like: ...

Why Spark viewengine renders unnecessary (or unexpected) quotes?

If i add pageBaseType="Spark.Web.Mvc.SparkView" in my web.config (necessary to fix intellisense), somehow it does not render links (probably not only) correctly anymore. This is how it's supposed to look like (and does, if page base type is not specified)=> This is how it looks when base type is specified=> Chrome source viewer sh...

ViewDataFactory and strongly typed master pages

Im trying to get my strongly typed master page to work in my ASP MVC 2.0 application. I have come far with the help of these two posts: Passing data to Master Page in ASP.NET MVC Strongly Typed ASP.Net MVC Master Pages Problem is that im not sure how to get that ViewDataFactory code to work, this is my code: BaseController.cs public...

asp mvc: specifying a view name does not change the url

I have an create action in my controller for the HttpPost. inside that action I insert the record in the db, and then return a view specifying a different action name, because I want to take the user somewhere else, such as to the details view of the record they just created, and I pass in the current model so I don't have to re-load th...