asp.net-mvc-2

ASP.NET MVC2 validation not working with drop down list in IE <8

I have a form with a dropdownlist rendered using Html.DropDownListFor(...). The view model field that corresponds with the dropdown list has a [Required(...)] attribute attached to it. This works fine on my local machine, but as soon as I publish to our development server, the drop down lists keep displaying the required error message, e...

Problems with Asp.net Mvc 2.0 Web.config.debug/release....System.UnauthorizedAccessException was unhandled by user code

Hi I am trying to use the debug and release versions of the webconfig but it never works. I am trying to do this for a 3rd party library that I am using called combres. http://combres.codeplex.com/ So I first put all the needed web.config code in the web.config. Now I have 2 different .xml files(thats where you put your javascript and...

MVC Dynamic Views From Url Slug

I am building my first .NET MVC web application and loving the simplicity and flexibility. I have however come to my first stumbling block. I have a list of items and if you are not logged in you will see a preview link I would like the link to direct to something like below: /preview/unique-slug The view should then allow me to disp...

Property-level validation errors hinder the validation of Class-level validation

Update after Bounty was awarded A new solution is coming up to this problem. Please refer to ASP.NET MVC 3 Preview 1 here: http://weblogs.asp.net/scottgu/archive/2010/07/27/introducing-asp-net-mvc-3-preview-1.aspx Look in the section Validation Model improvements, where you will see the solution to my problem. Original Post Referri...

MVC View Alternate Content

I have a view which I want to display different things based on a database field. An authenticated user who has purchased an item should see it in full Authenticated or Anonymous members who have not purchased the item should see a preview The only data this means changing is the title (prefix the word Preview) and changing the source ...

Syntax error when performing OrderBy<T> on an IEnumerable List

The error message I receive is: At least one object must implement IComparable The code causing this is below: private static IEnumerable<Result> setOrderBy(IEnumerable<Result> value, string order) { if (order.Equals("ASC")) { //value = value.OrderBy(c => c, new SearchService.ResultComparer<Attribute>()); value...

Route always goes to the first maproute

I'm trying to create URIs that look a little something like this: http://hostname/mobile/en/controller/action for mobiles OR http://hostnamem/en/controller/action for desktop (non mobiles) My Route table currently looks like this (Global.asax.cs) ` routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); routes.MapRoute( ...

Verify inline code when building ASP.NET MVC2 project

Is there some setting that can be turned on in Visual Studio 2010 to make it compile/verify the inline code in my MVC2 views when I hit build? Much like what happens when I open a view. ...

MongoDB, .NET MVC

I am building a library using mvc, mongodb and asp.net membership. When a user browses the site logged in (logged out is auto set to preview) I need to check if they have purchased the current movie and if they have they can see the full set of features otherwise they have to purchase the video or watch the preview. I have a Movie mode...

Dropdownlist selected item not getting displayed in Asp.net MVC

Hi all, I have implemented dropdown list in asp.net mvc using following code In controller int iSelectedNode=2; ViewData["ddlModels"] = new SelectList(Models, "ModelCode", "ModelName", iSelectedNode); In View <%= Html.DropDownList("ModelCode", (SelectList)ViewData["ddlModels"],"--Select--", new {id="ddlModel" })%> Still all th...

Asp.net MVC2 in VB.NET on Mono

I'm having problems running MVC2. I've compiled defult MVC project and deployed it on working mono setup (MVC1 works without problems, but only as C#, VB.net MVC1 fails with a message similar to this one). When I try to access MVC2 web (VB.NET version, C# works) I get this message: Compiler Error Message: VBNC30456: 'RenderPartial' is ...

WCF Session Service hosted in ASP.NET MVC 2.0 application

Hello, I have a must to host WCF Service using WCF Session mechanism. I've read http://msdn.microsoft.com/en-us/library/ms733040.aspx but it is not enough... My simple scenearion: I have solution with 4 projects. First - SessionWCF.Base, it is simple Class Library that contains base interface IServiceBase for my service. using Syst...

Model Binding to a List in asp.net mvc 2. Found example. Can't find where I'm going wrong.

I've based my work on Phil Haack's article here: http://haacked.com/archive/2008/10/23/model-binding-to-a-list.aspx I've also looked over several posts here on StackOverflow and I can't seem to derive an answer for my problem from them, though, they probably present a solution. I guess I need the bits broken down a bit more. I'm attemp...

How do you modify the URL in ASP.NET MVC when a form is submitted?

I am working on a web page that offers a form with a dropdown list to view data from a different year. The year is part of the URL routing that is configured. When the page loads, the URL can be something like: activitylog/department/year. When the form is submitted on this page, the URL does not change, even though the user has sel...

ASP.NET MVC2: Can't find controller

I have an MVC 2.0 web site that is using Areas. When I go to the default page (localhost/mywebsite/default.aspx), it correctly routes to the correct action in the correct controller and renders the default view correctly. But on the page I have several Html.ActionLinks, and these do not seem to be able to find the Controller. When I c...

ASP.NET2 ViewModel not Updating

Hi I'm using the NerdDinner MVC1 code. Created a viewmodel called DinnerFormViewModel: public class DinnerFormViewModel { public Dinner Dinner { get; private set; } public SelectList Countries { get; private set; } public DinnerFormViewModel(Dinner dinner) { Dinner = dinner; ...

how to both Compress and Minify content together?

hi, i know we can compress response by declaring Response.Filter as GZip or Delfalte streams, but how i can perform both compression and minification together? declaring new class that inherits Stream, then first performing minify on content, then compress that by GZip or Deflate depending on User-Agent supported each? ...

Require [Authorize] for all actions in Asp.Mvc2

Is there a elegant way to require all actions to require [Authorize] without having to use an AOP framework or similar? It seems to easy too forget to put the attribute on all controllers. I guess creating a base controller also can solve this, but again.. It's possible to forget to inherit from this one. ...

Routing with multiple parameters

Hi I am trying to add additional parameter in my route routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); routes.MapRoute( "CustomRoute", "{controller}.mvc/{action}/{id}/{recid}", new { action = "Index", id = "", recid = UrlParameter.Optional } ); ...

ASP.NET MVC, partial views and data

Can anyone elaborate on why you'd define ViewData["MenuData"] on every action for something like a dynamic menu? I have a simple partial view which renders a menu, I render this menu from within a master page. This is intutive for me comming from ASP.NET WebForms, but the only way for me to populate the menu is to pass ViewData["MenuDat...