asp.net-mvc-2

How to RESTful delete record Asp.Net Mvc 2

I have delete links in my Asp.Net Mvc2 application. /{controller}/Delete/{id} It seems using link to delete has a security risk. Don’t use Delete Links because they create Security Holes I found this Implementing RESTful Routes & Controllers in ASP.NET MVC 2.0 but I am not sure how to implement a simple delete functionality using the n...

Html.DescriptionFor<T>

I'm trying to emulate the Html Helper for "LabelFor" to work with the [Description] Attribute. I'm having a lot of trouble figuring out how to get the property from the helper though. This is the current signature... class Something { [Description("Simple Description")] [DisplayName("This is a Display Name, not a Description!")] publ...

intellisense for mvc html extesnsion methods

I am using VS 2010 MVC 2 to create a ascx file but the intellisense for html extension methods does not show up even after importing the System.Web.Mvc.html namespace. Do I miss anything? ...

Too many parameters in MVC2 Controllers or IIS problem?

I'm using a controller to call a stored procedure that requires 12 parameters. This works perfectly in debug mode locally (working against a remote database), but not when I publish it to my IIS 7 server. It complains about parameter #7, claiming it's not supplied with the URL. The URL call looks like this; http://localhost:50160/GetPl...

Good tutorial for ASP.net mvc 2

I am an experienced asp.net web forms developer using c# but i have never used asp.net MVC. As I am just starting out with mvc i would like to start with mvc 2. I am looking for a good intro/tutorial to help me understand the basics. I am aware of the Nerd Dinner but that is based around MVC 1. What would you guys recomend for me to...

MVC2 Client Validation isn't working when getting form from ajax call

I'm trying to use MVC2 client-side validation in a partial view that is rendered via $.get. However, the client validation isn't working. I'm not quite sure what the deal is. [Required(ErrorMessage = "Email is required")] public string Email { get; set; } <% using ( Ajax.BeginForm( new AjaxOptions { Confirm = "You sure?" } ) ) { %> <...

Making flexible C# code in MVC2 for Stored Procedures

Thanks to Darin Dimitrov's suggestion I got a big step further in understanding good MVC code, but I'm having some problems making it flexible. I implemented Darin's suggested solution, and it works perfectly for single controllers. However I'm having some trouble implementing it with some flexibility. What I'm looking for is this; To...

Physical path to application in global.asax

Guys, is it possible to get physical path to asp.net mvc 2 application inside Global.asax methods? UPD: sorry, i forget to say, that I need to get that path in Ninject IoC container configuration. This is a sketch of what i'm having now: public class MvcApplication : System.Web.HttpApplication { ... protected void Application_...

Why does this test fail?

I'm trying to test/spec the following action method public virtual ActionResult ChangePassword(ChangePasswordModel model) { if (ModelState.IsValid) { if (MembershipService.ChangePassword(User.Identity.Name, model.OldPassword, model.NewPassword)) { return RedirectToAction(MVC.Account.Actions.ChangePass...

ASP.Net MVC 2 Forms Authentication cookieless = "UseUri" while submit authorization fails

hi, I just started working with ASP.Net MVC 2. I created a new ASP.Net MVC application and created one vehicle controler with a database table connected with LINQ. Then created forms authentication mechanism for the application and tried to use the uri instead of cookies it was working smoothly but when i submit the form by creating ...

Html.hiddenfor does not return value

Hi I have a template partial view, which used to render a model named VerificationCode, this model has a element 'CaptchaGeneratedText' which is hidden in the view and set value by Html.HiddenFor(m=>m.CaptchaGeneratedText, captchaText), the problem is when view post, in the model validation the value of element 'CaptchaGeneratedText...

Which datagrid to use for ASP.NET MVC2 project?

Hi, I am developing a commercial MVC2 app that requires a grid that has callback update in some form to support 10,000+ rows. It should also support relatively rich content (icons, multiline descriptions etc). Although it requires the usual paging/scrolling/sorting features it does not need support for grouping. So nothing that special. ...

Why can't I install MVC (1 or 2) with Visual Web Developer Express 2008 RC1?

Hi all, I have installed VWD 2010 Express and love MVC2. I have an existing ASP.NET 3.5 website that I'd like to redevelop with ASP.NET MVC2 under VWD 2008 with the 3.5 framework (the host only supports .Net 3.5, and Express 2010 doesn't support targeting of .Net framework versions) I am however unable to install MVC2 with VWD 2008. T...

Asp.Net MVC ActionLink

Can anyone explain why the following happens? And how to resolve, Visual Studio 2010 and MVC2 <%= Html.ActionLink("Add New Option", "AddOption", "Product", new { @class = "lighbox" }, null)%> Results in /Product/AddOption?class=lightbox <%= Html.ActionLink("Add New Option", "AddOption", "Product", new { @class = "lighbox" })%> ...

Asp.Net MVC 2.0 client side validation VS 2010

There seems to be some confusion, at least for myself, on client side validation using the data annotations framework and <% Html.EnableClientValidation(); %> Most of the examples I have seen like on haacked.com use the following scripts jquery.validate.js MicrosoftMvcJqueryValidation.js However, visual studio 2010 asp.net mvc 2 ...

Built in method to encode ampersands in urls returned from Url.Action?

I am using Url.Action to generate a URL with two query parameters on a site that has a doctype of XHTML strict. Url.Action("ActionName", "ControllerName", new { paramA="1" paramB="2" }) generates: /ControllerName/ActionName/?paramA=1&paramB=2 but I need it to generate the url with the ampersand escaped: /ControllerName/ActionName/...

How to use NInject (or other DI / IoC container) with the model binder in ASP.NET MVC 2 ?

Let's say I have an User entity and I would want to set it's CreationTime property in the constructor to DateTime.Now. But being a unit test adopter I don't want to access DateTime.Now directly but use an ITimeProvider : public class User { public User(ITimeProvider timeProvider) { // ... this.CreationTime = timeProv...

Deploy ASP.NET MVC 2 to IIS 7.5 targeting .NET 3.5

I created an ASP.NET MVC 2 application in Visual Studio 2008. I set the release build to go through the ASP.NET compiler to precompile all the views, minify Javascript and CSS, clean up the web.config, etc. Since the production deployment is going to an IIS6 server, I set up my pseudo-production deployment on my Windows 7 machine to ha...

ASP.NET MVC 2: Mechanics behind an Order / Order Line in a edit form

In this question I am looking for links/code to handle an IList<OrderLine> in an MVC 2 edit form. Specifically I am interested in sending a complete order to the client, then posting the edited order back to an object (to persist) using: Html.EditorFor(m => m.orderlines[i]) (where orderlines is an enumerable object) Editing an Order th...

Should strongly typed partial views on one page in asp.net mvc-2 have one combined view model?

Hi guys, I have a question about asp.net mvc-2 strongly typed partial views, and view models. I was just wondering if I can (or should) have two strongly typed partial views on one page, without implementing a whole new view model for that page. For example, I have a page that displays profiles, but also has an inline form to add a q...