asp.net-mvc-2

Best Practices for mapping MVC Controllers to Views?

What are the best practices when it comes to mapping controllers to views? For example, say for the urls mysite.com/login and mysite.com/register...I can have my LoginController and a RegisterController map to Login/Index.aspx and Register/Index.aspx views. Alternatively, my HomeController could handle both of these and map them to Hom...

How do I put a strongly-typed-view WebForms .aspx template in a nonstandard location in ASP.NET MVC2?

So, I personally think this is sort of whack. I put a .aspx template in a nonstandard location. In this example, it has a virtual path of ~/Content/Sites/magical/Index.aspx. I then created my own view engine as a test, which extends WebFormsViewEngine: public class MagicalWebFormsViewEngine : WebFormViewEngine { public override ...

Asp.Net MVC2 Error in view

Hi Guys, I am new to MVC and I have been following Steven Andersons Pro ASP.Net Mvc 2 framework book but have encountered the following issue. The following line of code that sits in my site.Master file throws the following error: <% Html.RenderAction("Menu", "Nav"); %> {"Error executing child request for handler 'System.Web.Mvc.Htt...

Global routing parameter in ASP.NET MVC

When a user clicks on a link, I want to log some information. I can't do an AJAX request because if they clicked on a link, the page will unload (since they're going to a new page), and I don't want to force them to stay on the page until a synchronous event finishes. So one idea I had was to add a parameter to the url. I.e. the urls w...

asp.net mvc outbound routing from a GET form post

I have a route that looks like this: new { controller = "ControllerName", action = "PhotoGallery", slug = "photo-gallery", filtertype = UrlParameter.Optional, filtervalue = UrlParameter.Optional, sku = UrlParameter.Optional} and I have a form that looks like this: <%using(Html.BeginForm("PhotoGallery", "ControllerName", FormMethod....

Pluggable ASP.NET MVC framework query

I am trying to create a pluggable ASP.NET MVC framework. I have extensively used Prism (CAB for silverlight) and am a huge fan and wish to implement the following items in my pluggable ASP.NET MVC framework The framework will have a host to load the unity container and other infrastructure items like logging services and all. Plugins w...

Castle Windsor with MVC 2.0 and Areas

Hi guys Wanted to ask a quick question regarding castle windsor and implementing IoC for Controllers in Areas. Does Castle 2.5 support MVC 2.0 areas? My Castle config works ok for my root controller in the root of my site but any area controllers are not found with a The IControllerFactory 'XXX.Castle.WindsorControllerFactory' did no...

Global.asax Exception Handling and HTTP Error Codes

I have a fairly standard MVC2 app running on 4.0 and under IIS6. I took the wildcard filter approach to route all requests to the asp.net ISAPI filter. So far so good. I have now added some code to Application_Error in the global.asax to trap exceptions and email me the stack, etc. This also works fine. But, I am receiving all kinds of...

TimeZoneInfo.ConvertTime doesnt Covert anything

Running asp.net mvc 2 on win 7 with .net 4.0 I have a controller action method that receives 2 DateTime objects from a form. The UI on the form uses the jQueryUi datepicker (not sure if that maters). The user who fills out that form will ALWAYS be entering the date/time in Hawaiian time zone. I want to convert that to UTC time and ...

Understanding client and server side validation using data annotations

Hi, I'm using MVC 2. I have a question regarding client and server side validation. Lets say I have a class, and it has 3 properties as such: [Required(ErrorMessage = "Required")] public object Property1 { get; set; } [Required(ErrorMessage = "Required")] public object Property2 { get; set; } [Required(ErrorMessage = "Required")] p...

TryUpdateModel not updating object after property value has changed

Hi, I'm using MVC 2 and EF4. If have a view that displays my Application (class) properties. Not all the properties are displayed in the view. There are a couple of the properties that need to be set once the submit button is clicked. I'm getting client validation to pass, but my server validation is still failing. I receive an App...

Anti-forgery token validation error in Firefox and Opera during first try of posting a partial view

Hi, I am coding an ASP.NET MVC 2 application that does the following: A view is loaded. Clicking on a button opens a jQuery UI Dialog that loads a partial view inside of it. (it loads a brand new instance everytime the dialog is opened using the "load" method of jQuery dialog). This partial view has a form (AjaxForm) that gets posted ...

ResourceManager not selecting correct resource set when using custom culture

I have created a localized MVC website using the code found on this blog by Alex Adamyan. This is working great if I use an existing culture. However, I am trying to localize for Tagalog (tl or tl-PH). Windows does not have this culture built in so I have created one (I have tried both tl and tl-PH) as per the code below: public stat...

Populating Dropdownlist Using MVC2 Based On Another Dropdownlist (Cascading DropDownList)

I am making an application that deals with vehicles. I need two DropDownLists: Makes: All Vehicle Makes Models: Models that belong to the selected value of the Make DropDownList How is this done in MVC2? My Idea: Do I use an ajax call when my first list is selected and then pull back the Models to bind to the Model DDL? How woul...

"No parameterless constructor" error instantiating Controller registered w/Windsor Container

Using MVC and trying to use dependency injection for controllers, but when I try to call a method on a controller that takes a dependency, I get the "no parameterless constructor" error. Here's my setup: ProductRepository : IProductRepository ProductService : IProductService { public ProductService(IProductRepository repository)...

Attributes on Areas in ASP.NET MVC 2?

The "Admin" area in my app contains a bunch of controllers, and it's a bit repetitive to put an [Authorize] attribute on all of them. Is there a way of telling the framework that all controllers in a certain area should have certain attributes? Edit: Inheritance is not a solution in this case. First of all the controllers already inheri...

Which is the way to add MVC behavior to existing classes?

Hello, I have a Windows Form project that I would like to migrate toward a web application using ASP.NET MVC2. In this project I have some POCO classes as in this example that are part of a class library and that I would like to use with a binary reference public class Person { public int PersonID { get; set; } public string ...

building a website supporting many languages/cultures

I am building my first ASP.NET MVC site and this site needs to be in 2 languages. When a user selects a language from the menu, the site would present itself in that language. The content likely will be loaded all from resource files. Can I respond to a change in the culture definition at runtime so it load the correct resource file? ...

Update A Partial View From Another Partial View - ASP.NET MVC2

I want to have two partial views, one for SEARCH and one for SEARCHRESULTS. I want to update SEARCHRESULTS when the "Search" Button is clicked on the SEARCH partial view form. SEARCHRESULTS needs to have the form data fed to it from the SEARCH partial view. I'm not totally sure how to go about this. Can I update the SEARCHRESULTS par...

Controlling the FormsAuthentication createPersistentCookie expiration

In an ASP.NET MVC2 app, we have the standard login action... if (ValidateUser(model.Email, model.Password) { FormsAuthentication.SetAuthCookie(model.Email, model.RememberMe); ... where the second parameter to SetAuthCookie is createPersistentCookie with the following documentation: createPersistentCookie Type: System.Boolean ...