asp.net-mvc-2

ASP.NET MVC: Proper way to consume/link to a resource from another controller

In a view, I want to consume some Json produced by an action on another controller. I don't think I ought to be arbitrarily specifing the url for the resource because if I say something like "/Dealerships/GetDealerData" and if my application is a virtual directory at say "www.somesite.com/MyApplication", then my reference to that resourc...

Foreach on IEnumerable property and CheckBoxFor in ASP.Net MVC

I believe this question applies to any of the "For" Html helpers, but my specific problem is using CheckBoxFor... I have a model that is of type IEnumerable, where rights is a simple POCO. This model is actually a property of a bigger model that I created an EditorTemplate for. Here is the bigger picture of my model: public class big...

ASP.MVC routes without Details action

I'd like to have URLs that are even shorter than /{Controller}/{Action}/{Id}. For example, I'd like {Controller}/{Id}, where {Id} is a string. This would allow for simple paths, e.g. Users/Username, Pages/Pagename, News/Newsname. I like this better than requiring the /Details action in the URL (Users/Details/Username), which is less e...

How to set order of appearance for fields when using Html.EditorFor in MVC 2?

I have the following classes in my Model: public abstract class Entity : IEntity { [ScaffoldColumn(false)] public int Id { get; set; } [Required,StringLength(500)] public string Name { get; set; } } and public class Model : SortableEntity { [Required] public ModelType Type { get; set; } [ListRequired] ...

MVC2: Validating User Input / Best Practices

I'm trying to validate user input, in particular user passwords. I have some jQuery validation, but of course I also need to validate on the server side. Now my request comes in to the controller, which will hand it off to a UserService. Everything is loosely coupled, so the controller really doesn't know too much about the inner UserSer...

Why is the w3wp.exe process looking on file system when an ASP.NET MVC controller is accessed?

Was just wondering if this was normal behavior as I'm fairly new to ASP.NET MVC. When I monitor the site usage via procmon I see the following: 7:19:17.0053886 PM w3wp.exe 3992 QueryOpen C:\www\inetpub\ControllerName.mvc\ActionName PATH NOT FOUND (This site is setup to run on IIS6/MVC2 - the reason for the .mvc extention) This is ha...

How to update one to many relationship entity from same view?

Table Product Product Id Product Name Table Supplier SupplierId ProductId SupplierName When I create a New Product, I want to have a textbox to enter a supplier as well on the same view. Is this a good practice? Since Product can have many Suppliers, I want to be able to add more Supplier records from the same view. How do I do that? ...

MVC2 Modelbinder for List of derived objects

I want a list of different (derived) object types working with the Default Modelbinder in Asp.net MVC 2. I have the following ViewModel: public class ItemFormModel { [Required(ErrorMessage = "Required Field")] public string Name { get; set; } public string Description { get; set; } [Scaffold...

Should I use Url.Content() or ResolveUrl() in my MVC views?

When building code like this: <script type="text/javascript" src="<%=ResolveUrl("~/js/js.js")%>"></script> or <input type="image" src="<%=ResolveUrl("~/img/submit.png")%>" /> Should I use Url.Content or ResolveUrl()? What's the difference? ...

Are multiple asserts bad in a unit test? Even if chaining?

Is there anything wrong with checking so many things in this unit test?: ActualModel = ActualResult.AssertViewRendered() // check 1 .ForView("Index") // check 2 .WithViewData<List<Page>>(); // check 3 CollectionAssert.AreEqual(Expected, ActualModel); // check 4 ...

Is ASP.NET MVC 2.0 released yet?

Does anyone know if this has been released yet? I went to asp.net and the Windows PI installs MVC 2 and it doesn't mention anything about RC's but then Scott Guthrie doesn't mention anything on his blog either. ...

DisplayName attribute from Resources?

Hello! I have a localized application, and I am wondering if it is possible to have the DisplayName for a certain model property set from a Resource. I'd like to do something like this: public class MyModel { [Required] [DisplayName(Resources.Resources.labelForName)] public string name{ get; set; } } But I can't to it, as the c...

Can I run asp.net mvc 1 on .net 4?

I have a asp.net mvc site that references a couple of libraries. Recently I discovered that it is necessary to migrate those dlls to .net 4 (I mean compile them for .net 4). Can I run asp.net mvc 1 on .net 4. Migration to asp.net mvc 2 is postponed because of the removal of response.WriteSubstitution(...) method. ...

Inclusion Handling in MVC 2 / MVCContrib

I'd like to improve my page by combining and minifying javascript and CSS files. Since MVCContrib already contains a project called IncludeHandling, I took a look at that which unfortunately left me with unanswered questions: There is quite a set of interfaces and objects involved in the process. Now I'm using Ninject.Mvc, but it seems ...

Visual Studio 2010 RC + ASP.NET MVC 2

Now that ASP.NET MVC 2 is out, I tried to install it on my development machine, which already has Visual Studio 2010 RC installed and I got this error message during installation Component Microsoft ASP.NET MVC 2 has failed to install with the following error message: "A different version of ASP.NET MVC 2 is already installed on yo...

How do I route different domains to an Area in asp.net mvc 2?

There are several similar questions to this on stack overflow, but I couldn't find one that actually answered my question. I am writing an asp.net mvc application which will need to have a front end sign up peice (home page, sign up page, account management, etc) and then allow each account to point their own domain to us and have it go...

Inheritance with POCO entities in Entity Framework 4

I have a Consumer class and a BillableConsumer : Consumer class. When trying to do any operation on my "Consumers" set, I get the error message "Object mapping could not be found for Type with identity Models.BillableConsumer. From the CSDL: <EntityType Name="BillableConsumer" BaseType="Models.Consumer"> <Property Type="Stri...

Server Error in '/' Application. - The resource cannot be Found.

I am new to ASP.NET MVC 2. I do not understand why I am receiving this error. Is there something missing that i'm not referencing correctly. I'm trying to create a simple jquery autocomplete online search textbox and view the details of the person that i select using System; using System.Collections.Generic; using System.Linq; using...

How to Add, Edit and Display one to many relationship entities in ASP.Net MVC 2?

I am looking for best practices conforming to the MVC design pattern. My Entities have the following relationship. tblPortal PortalId PrortalName tblPortalAlias AliasId PortalId HttpAlias Each Portal can have many PortalAlias. I want to Add a New Portal and then Add the associated PortalAlias. I am confused on how I should structure ...

What is the equivalent of ASP:Timer control in ASP.NET MVC?

Hi Recently i am working on migrating the ASP.NET Web application to MVC. I am wondering if there is any equivalent of ASP:Timer control in ASP.NET MVC Framework. So that this Timer control can automatically check for a particular value from the Database once in every couple of Seconds(that we specify). If there is no equivalent of Ti...