asp.net-mvc-2

Is this the correct pattern to return different views from an ASP.NET MVC controller?

I have an application that has an public 'end user' mode and a 'back office' mode. Both 'modes' pretty much share the same controller logic but the user interfaces for these different 'modes' are radically different. Using the out of box default routing that you get when a project is created for the first time I have something like the ...

DataAnnotation attributes not working in Asp.Net MVC2

Hello, I am having trouble with the with mvc2. I am using the Entity Framework as my ORM. I have used the POCO Entity Generator to create POCO objects. I moved the generated objects to a separate project. I followed steps outlined here(Tutorial). This is my project structure Sports.Data - Entity Frmework and Data Access Sports.Entiti...

How can I customize the deserialization of JSON in ASP.NET MVC?

I have a controller action that is receiving a complex object via JSON. The object has a property on it that is declared as an abstract type. Currently, the action method never gets executed because when the JSON object is deserialized it chokes on the abstract type. How can I customize the deserialization phase so that I can supply th...

What is the best approach to do ASP.NET MVC & AJAX via JSON?

In ASP.NET webforms I used to write AJAX apps where the client would communicate to the server using web services or page methods and JSON. I'm new to ASP.NET MVC and have found that one could use web services or controller actions that use JSON. Are there other options? Should I use web services or controller actions and why? ...

How to add Dynamic Data to an Existing MVC 2 Web Application

I'm a total noob at Dynamic Data and I need help. I have an existing MVC 2 .net web application in which I would like to include Dynamic data. This here worked fine, but I wanted to have a Dynamic data project in my solution and then add a pre-build event that would copy only the needed files from the DynamicData project to my webApplic...

MVC 2 - Nested areas

In MVC 2 we can create areas easily. Now my question is related to nested areas (areas inside of areas). Select my "father" area folder, Right-mouse-click > Add > NO option for a new Area. Is it possible to do it in some other way ? or will this option be available in the near future? ...

What is difference between these tags <% <%: <%= in ASP.NET MVC 2 ?

Hello The title contain my whole question. ...

Asp.Net MVC : Execution of the child request failed. Please examine the InnerException for more information.

I'm recieving the following error message, A public action method 'RenderMenu' was not found on controller 'Web.Controllers.SiteController'. However this action DOES exist and the controller does exist (As it work everywhere on the site) I looked at the inner exception. Execution of the child request failed. Please examin...

What is the recommended approach to providing user notifications / confirmations in MVC?

A common scenario I encounter is providing notifications / confirmations to users after they have performed an action to inform them of success. For example, suppose a user provides feedback on a feedback form and then clicks Submit Feedback. You may want to display a 'Thanks for your Feedback' message after you have performed some vali...

ASP.NET MVC Custom Membership Guide

Hello There I am trying to make the move from PHP to ASP.NET. I have about 10 years experience with PHP, and 4 with C#. But I having problems with the authentication and membership system in ASP.NET. So i have spend quit a lot of time finding a guide on how to create a membership provider for a custom database setup from scratch, but i ...

jquery iterate through dynamic complex object submit to asp.net mvc action

I'm trying to iterate through a complex type binding in jQuery to submit the Json representation through to an IEnumerable action parameter. Html <input type="hidden" value="0" name="value.index" /> <input type="text" value="textone" name="value[0].InputValue" id="value[0].InputValue" /> <input type="hidden" value="0" name="value[0].Id...

HttpApplicationState not available in an MVC controller

Hi, I'm using MVC2 and VS2010 developing a website and need to use Application State global values. I can set a value like 'Application["hits"]=0;' in Global.asax but when trying to use the same in an MVC controller always get the following error: The name 'Application' does not exist in the current context I have also tried using in...

model binding how collect data from <div>

I have model public class MyModel { public string Name { get; set;} } I have html code <div id="Name">Important data</div> In Controller, i have a method public ActionResult Index (MyModel model) { model.Name == "Important data" } Is it real, using standart model binder? thx) ...

Call MVC file download action method from jQuery

If I have the following MVC Action: [AcceptVerbs(HttpVerbs.Post)] public ActionResult GetDocument(int id, string fileName) { // ..... // return File(fileStream, "text/plain", fileName); } I want to call the action on a click of a table row using jQuery. But I'm a bit confused, because I don't think I want an Ajax call here do...

How to develop a https:// area using mvc2 and IIS 6 on your local machine

General question to experienced developers: I want to develop a secure an area on my local machine which I will then roll up to the remote server. I am using IIS 6 with MVC2 on VS 2008. I understand that the SSL provider will only issue a certificate to a given domain, which while I find this logical, cannot figure out how to build l...

Anyone Using a Custom ViewMasterPage?

Lately when I've been building my asp.net mvc apps I tend to have a number of items that consistently need to be calculated, formatted and configured in my master pages. Some of these items include: I like to attach specific classed to the body tag like WordPress does to help my CSS out. I usually attach the name of the action, control...

In MVC2 IIS6 with a SSL Certificate, can put it in root and choose secure page by controller action?

I have been trying to figure out the best way to make a secure membership area. I considered doing something like https://www.users.examplesite.com/ but it seems like a lot of trouble to do, also I am using areas in the rest of the app and that looks like double the complication. Could I just assign the SSL certificate to the root and ...

Missing extension methods in HtmlHelper using NHaml

Hi, I discovered NHaml some days ago and it's a great project. When I try to use MVC2 Html helpers like Html.LabelFor(), Html.TextBoxFor(); the views won't compile. Example: error CS1061: 'System.Web.Mvc.HtmlHelper' does not contain a definition for 'LabelFor' and no extension method 'LabelFor' accepting a first argument of type 'Sys...

Problem with custom routes

I'm using the following route routes.MapRoute( "PatientList", "User/{SearchName}/{LocationID}/{Page}", new { controller = "User", action = "Index", SearchName = "", LocationID = 0, Page = 1 } ); It fails on the following URL: /user//1/1 Can anyone tell me what I'm doing wrong? ...

Querying using Entity Framework via Stored Procedures

I am quite frustrated with Entity Framework as most of the tutorials only show how to use it with one or two tables, and not multiple tables with relations. I was thinking of the following 'hack' to get my job done quickly: Create and Import procedures in the EF ORM to do most of the CRUD where multiple tables come into picture. What a...