asp.net-mvc

ASP.NET Collection Model Binding Nested Form Problem

I have a partial view that is bound to an object Cart. Cart has a collection of CartLines. My view is below: <tbody> <% foreach (var line in Model.Lines) { %> <tr> <td align="center"><%=Html.CatalogImage(line.Product.DefaultImage, 80) %></td> <td align="left"> <%=Html.Actio...

How to "DRY up" C# attributes in Models and ViewModels?

This question was inspired by my struggles with ASP.NET MVC, but I think it applies to other situations as well. Let's say I have an ORM-generated Model and two ViewModels (one for a "details" view and one for an "edit" view): Model public class FooModel // ORM generated { public int Id { get; set; } public string FirstName { ...

asp.net mvc area problem: The view 'Index' or its master was not found.

The view 'Index' or its master was not found. The following locations were searched: ~/Views/ControllerName/Index.aspx ~/Views/ControllerName/Index.ascx ~/Views/Shared/Index.aspx ~/Views/Shared/Index.ascx I got this error when using ASP.Net mvc area. The area controller action are invoked, but it seems to look for the view in the 'base...

Passing Information Between Controllers in ASP.Net-MVC.

This is a duplicate of http://stackoverflow.com/questions/1936/how-to-redirecttoaction-in-asp-net-mvc-without-losing-request-data Hi, I have come into a problem which is making me scratch my head a little bit. Basically I have a login page Login.aspx , which has username and password fields, as well as an important little checkbox. Th...

NerdDinner exceptions and custom errors

In this tutorial in Details action Scott uses if (dinner == null) return View("NotFound"); else return View("Details", dinner); to return 404 Not Found message view. But in my downloaded source code for NerdDinner there are these lines: if (dinner == null) { return new FileNotFoundResult { Message = "No...

Have you used ASP.NET MVC with jQuery's AJAX to power your navigation?

I've used jQuery's AJAX on a webforms app (kill me), but it worked fairly well after fighting with the webforms framework for a good while. I had links that would load aspx pages into a content div through jQuery's AJAX functions. One of the biggest issues was dealing with state without using session. I ended up using cookies that were u...

ASP. NET MVC: Mapping Entities to View Model

I'm trying to clean up my action methods in an ASP.NET MVC project by making use of view models. Currently, my view models contain entities that might have relationships with other entities. For example, ContactViewModel class might have a Contact, which might have an Address, both of which are separate entities. To query for a list of C...

Ninject 2 Property Injection for ActionFilterAttribute not working

I have a method attribute which expects several properties to be injected by Ninject 2, but userSession and jobRepository are coming up as null: [AttributeUsage(AttributeTargets.Method, AllowMultiple = false)] public class JobAttribute : ActionFilterAttribute { [Inject] private IUserSession userSession; [Inject] private...

asp.net mvc actionlink difficulties

i have an actionlink in my view <%= Html.ActionLink("action","controller") %> the action has a [AcceptVerbs(HttpVerbs.Post)] atttribute, and the lactionlink doesn't work. how to make it work by "POST"?? ...

ASP.NET MVC - PartialView not refreshing

I have a user control: VendorDDL.ascx, with the following code: <%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<List<MeetingCalendar.Models.Vendor>>" %> <table> <tr> <th></th> <th> VendorId </th> <th> VendorName </th> </tr> <% foreach (var item ...

Testing an ActionResult with a Form View Model

I know this has been asked before but I can't find it so... Say I have a controller called HomeController and it has an action called Login. My Login action takes a model called LoginFormViewModel. Inside my action I can write code like; public ActionResult Login(LoginFormViewModel loginFVM) { if (ModelState.IsValid) ...

Set default area - Avoiding `, new {area = ""}` on each link on the site.

This code is inside the master page: <li><a href="<%=Url.Action("Action", "Controller") %>">Main site link</a></li> <li><a href="<%=Url.Action("AreaAction", "AreaController", new {area = "Area"}) %>">Area link</a></li> All the links works good till I'm going to the Area Link. When I go there all the routes of the main area don't wor...

Data lookup in route constraints?

Hi, Is it a recommended practice to do data lookup in route constraints, or should they be kept lightweight? I would like to have a route constraint that triggers a 404 if a user tries to access a product that does not exist - i.e.: /en-US/products/myproductcode But I'm concerned about the performance implications, even if the lookup...

Link to new popup-window, print area of document

Hello I was wondering how you best open a new window and show a view there using mvc? and is there a way to using jquery or similar, to print an area of a document? lets say everything within a div? /M ...

How to return different view, but presererve ViewModel in OnActionExecuting

Hi! I'm trying to return a different view if a condition is met. I want to preserve the Model passed into the view from the action. protected override void OnActionExecuting(ActionExecutingContext filterContext) { var subAction = filterContext.RequestContext.RouteData.Values["subaction"].ToString(); var action ...

asp.net mvc area - best prectice

I'm currently building a CMS system, and I need to have an easy way include or exclude components. My first think was to use asp.net mvc area feature, to identified each component on itself. But from what I see, the area feature has problems, so maybe it not that good idea. What you guys think? What ways we have in asp.net mvc achieve...

Edit/Review/Save scenario in mvc

I am looking for clean approach on the "Edit/Review/Save" scenario in asp.net mvc: Our customers can "edit" their accounts information which will affect their monthly premium, but before saving the information we need present them with "review" screen where they can review their changes and see a detailed break down of their monthly pre...

Is this code threadsafe or why am I concern with Url.Helper

Say that I have public static class M { public static string Concat(string a, string b) { return N.AddOne(a, b); } public static string Concat2(string a, string b) { return SomeThreadSafeMethod(a, b); } } public static class N { public static string AddOne(string a, string b) { retur...

Some Issues about Rob Conery's repository pattern !

Hi, I'm trying to apply repository pattern as Rob Conery's described on his blog under "MVC Storefront ". But i want to ask about some issues that i had before i apply this Design pattern. Rob made his own "Model" and use some ORM "LinqToSql" to mapp his database and then he used some interfaces and custom Repositories on top of these...

ASP.NET MVC. Extending HtmlHelper vs Custom class

What are the advantages of extending HtmlHelper instead of creating a Custom Class. f.e. <%= Html.Table(data) %> vs <%= CustomClass.Table(data) %> ...