asp.net-mvc-2

Can't select View Content dropdown when adding view in MVC using Interfaces

I have my Model defined externally in two projects - a Core project and an Interface project. I am opening the Add View dialogue from my controller, and selecting Create a strongly typed view. In the drop down list, I can select the concrete types like MyProject.Model.Core.OrderDetails, but the interface types like MyProject.Model.Int...

ASP.NET MVC: How to Display custom object properties in View page

I am trying to add ASP.NET MVC features(Especially Routing) to my already existing ASP.NET Web application.I added a Controlled and View (an asp.net page) .Now i want to know how can i display the details of object of my custom class( Ex : User) in the view ? Can assign the object in ViewData collection and render it in the view ? Hows ...

ASP.NET MVC 2 Controller parameter value getting truncated from what is posted

I have an ASP.NET MVC 2 application (.NET 4) that takes an HTTP post with two parameters. The second parameter is a big chunk of html. The controller action is shown below. [ValidateInput(false)] [AcceptVerbs(HttpVerbs.Post)] public ActionResult TriangleUpdate(string userId, string html) { var user = _udRep.GetU...

How can I highlight empty fields in ASP.NET MVC 2 before model binding has occurred?

I'm trying to highlight certain form fields (let's call them important fields) when they're empty. In essence, they should behave a bit like required fields, but they should be highlighted if they are empty when the user first GETs the form, before POST & model validation has occurred. The user can also ignore the warnings and submit the...

ASP.NET MVC Route Default values

hi, i defined two routes in global.asax like below context.MapRoute("HomeRedirect", "", new { controller = "Home", action = "redirect" }); context.MapRoute("UrlResolver", "{culture}/some", ...

ASP.NET MVC 2 Tutorial

Good Morning, I would like to know if there is a tutorial similar to Nerd Dinners but specifically for MVC 2 rather than just the vanilla MVC 1? Many Thanks, Joel ...

asp.net mvc2 - two (or more) views using same controller?

Is it possible that two different views use the same controller? I have very complex controller that displays some data. Now I need to display this data (which is retrieved using ajax) in two partial views because I want to place them on different positions in layout. ...

Single website multiple connection strings using asp mvc 2 and nhibernate

Hi In my website i use ASP MVC 2 + Fluent NHibernate as orm, StructureMap for IoC container. There are several databases with identical metadata(and so entities and mappings are the same). On LogOn page user fiils in login, password, rememberme and chooses his server from dropdownlist (in fact he chooses database). Web.config contains...

How do I run asynchronous code in asp.net mvc 2?

I tried this: BackgroundWorker bw = new BackgroundWorker(); bw.DoWork += (o, e) => { SendConfEmail(); }; bw.RunWorkerAsync(); but it didn't work. SendConfEmail takes a while to run. I guess it's because BackgroundWorker is designed for winforms not webforms. Any ideas how I can solve the problem? ...

Errors when creating a custom Querable object with MVC and Subsonic pagedlist

hiya, i have the following code but when i try and create a new IQuerable i get an error that the interface cannot be implemented, if i take away the new i get a not implemented exception, have had to jump back and work on some old ASP classic sites for past month and for the life of me i can not wake my brain up into C# mode. Could you...

ASP.NET MVC form GET passing array

I have a form with a collection of checkbox's for a refine search function on my website. I am trying to pass an array in a form GET but the URL looks like: /search?filter=foo&filter=bar&filter=green Is there a better way to pass this in MVC? Possible like /search?filter=foo,bar,green Thanks in advance. ...

Cannot resolve view when view is in subdirectory

We have a MVC 2.0 / c# 4.0 application that we develop visual studio. We have a part of the site (admin) that we have put in it's own sub directory and with its own routing rules: routes.Add("DomainRoute", new DomainRoute( ConfigurationManager.AppSettings["adminDomain"], // Domain with parameters "{controller}/{a...

Common MVC 2 Pitfalls

I'm surprised this hasn't been asked before...or maybe I just don't see it. Anyway, I'm finally straying from the comfort of ASP.NET Web Forms and exploring the world of MVC2. I've done the nerdinner walk-through and it was fairly straightforward. Now I am getting a little more adventurous and building an MVC2 app on my own and would li...

How do I install ASP.NET MVC 2 Futures?

I want to use the DataAnnotations.DisplayAttribute.Order property to arrange my fields when using the DisplayForModel and EditorForModel methods. Related question: Does the DataAnnotations.DisplayAttribute.Order property not work with ASP.NET MVC 2? I think that I need to use the ASP.NET MVC 2 Futures. But I can't get it to...

Share Json data between Asp.Net MVC 2 and Asp.Net server side C# code?

I created and love my Asp.Net MVC2 application. It's a very nice DDD app with Domain Model classes, View Model classes, a repository, and Json action methods to expose data. My coworker wants to share my data with his Asp.Net Forms based C# code. He wants to pull through the Internet a class definition (like a Data Contract), then fil...

Using DataAnnotations with Entity Framework

I have used the Entity Framework with VS2010 to create a simple person class with properties, firstName, lastName, and email. If I want to attach DataAnnotations like as is done in this blog post I have a small problem because my person class is dynamically generated. I could edit the dynamically generated code directly but any time I ...

What new DataAnnotations are included in ASP.NET MVC2 ?

Hi, I'm reading about enhacements in ASP.NET MVC 2, and as we see, there is a topic about "Support for DataAnnotations Attributes": RangeAttribute, RequiredAttribute, StringLengthAttribute, and RegexAttribute. Were they available in MVC v1 ? ...

ASP.NET MVC 2 Cancel Asynchronous Action

The MSDN documentation for using an asynchronous controller mentions choosing an asynchronous controller when you want to provide a way for users to cancel requests. I couldn't find any documentation related to actually allowing users to cancel asynchronous requests, however. Is there a way to indicate to ASP.Net and/or the MVC framewo...

mvc2 routing subdomain to area does not work.

I'm using the code from this blog: http://blog.maartenballiauw.be/post/2009/05/20/ASPNET-MVC-Domain-Routing.aspx to implement subdomains. My goal is to have an area /admin/ that works with urls like: admin.localhost\test\index while my main application is localhost\home\index. I've implemented the following route: context.Routes.Add(...

MVC: Display objects : best practices?

Hi Guys, Inside a ASP.Net MVC 2.0 project I'm facing a few naming convention issues. For display purposes I'm using a few object residing in my Model directory inside the MVC Web Project: Object: CatalogView : Sort of wrapper object to group all objects I need for the catalog view (aspx) --- ShoppingBagPartialView ...