asp.net-mvc

How to enforce unique-field validation in MVC

I am in the way building some MVC Application and I really love the Data Annotations support in MVC. The build in support is good enough to enforce simple validation checkup. I wonder, how to implement unique-field validation using custom data-annotation ? For example, I have a view model that need the user to register a new login name, ...

web.config + asp.net MVC + location > system.web > authorization + Integrated Security

Hi guys I have an ASP.Net MVC app using Integrated Security that I need to be able grant open access to a specific route. The route in question is '~/Agreements/Upload' and the config I have setup looks like this: <configuration> ... <location path="~/Agreements/Upload"> <system.web> <authorization> ...

Setting up a SQL Membership Provider and attaching the MDF file in Visual Studio 2008

I'm trying to set up a SQL Membership Provider for an ASP.NET MVC 1.0 and I'm having problems setting up the tables and stored procedures in the database. I've tried attaching both the applications current database and a blank database to my local SQLEXPRESS instance (using SSEUtil) and then running the aspnet_regsql wizard against them...

ASP.NET MVC POST Parameter into RouteData

I'm using jQuery to POST an Id to my route, for example: http://localhost:1234/Load/Delete with a POST Parameter Id = 1 I'm only using the default route in Global.asax.cs right now: routes.MapRoute( "Default", "{controller}/{action}/{id}", new { controller = "Home", action = "Index", id = "" } ); When I perform the POST, ...

How to disable ASP.NET MVC url routing

Just would like to know how do I disable URL Rewriting in asp.net MVC. I don't need url rewriting in my application and would like to turn it off. Reason: I am aware that url rewriting uses reflection and would like to save a few cpu cycles by avoiding it. Thanks ...

asp.net mvc ajax form helper/post additional data

I would like to use the ajax helper to create ajax requests that send additional, dynamic data with the post (for example, get the last element with class = blogCommentDateTime and send the value of that last one to the controller which will return only blog comments after it). I have successfully done so with the help of jQuery Form p...

asp.net mvc client side validation; manually calling validation via javascript for ajax posts

Under the built in client side validation (Microsoft mvc validation in mvc 2) using data annotations, when you try to submit a form and the fields are invalid, you will get the red validation summary next to the fields and the form will not post. However, I am using jquery form plugin to intercept the submit action on that form and doing...

missing a using directive or an assembly reference

I'm in the process of writing a small asp.net mvc application that is using the northwind.mdf. When building the solution I get this error: Error 1 The type or namespace name 'Order' could not be found (are you missing a using directive or an assembly reference?) Order is a table in the northwind database. any help is most appreciate...

Validation on DropDownListFor not working with DataAnnotations

If I have a drop down list as follows <div class="editor-label"> <%= Html.DropDownListFor(model => model.CardDetail.SelectedCardSchemeId, Model.CardDetail.CardSchemes, "Select")%> </div> and in my model I am using DataAnnotations [Required(ErrorMessage = "* Required SelectedCardSchemeId Message")] public int SelectedCardSchemeId ...

Difference between Master Page and MVC View Master page

Please check below screen shot. What is main difference between Master Page and MVC View Master page. When I should use Master page and when I should use MVC View Master page. Thanks. ...

Multiple Actions (Forms) on one Page - How not to lose master data, after editing detail data?

Hello all, I've got a form where users can edit members of a group. So they have the possibilty to add members or remove existing members. So the Url goes like ".../Group/Edit/4" Where 4 is the id of the group. the view looks like this <asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server"> <% using (Html.Beg...

Visual Studio: What approach do you use to 'template' plumbing for similiar projects?

When building ASP.NET projects there is a certain amount of boilerplate, or plumbing that needs to be done, which is often identical across projects. This is especially the case with MVC and ALT.NET approaches. [I'm thinking of things such as: IoC, ORM, Solution structure (projects), Session Management, User Management, I18n etc.] I w...

How do I identify an ASP.NET MVC website?

I am trying to determine whether a company has websites built with ASP.NET MVC in their portfolio. Is there a reliable way of determining that without asking them assuming that I can visit the website in question in my browser? This might seem simple, but I wasn't able to find this information online. I would think that the lack of views...

How to configure IIS to serve my 404 response with my custom content?

This question is related to this, hopefully better phrased. I would like to serve a custom 404 page from ASP.NET MVC. I have the route handler and all the infrastructure set up to ensure that nonexistent routes are handled by a single action: public ActionResult Handle404() { Response.StatusCode = 404; return View("NotFound"); ...

getJSON() parameter length is more than 2500 for IE6 or IE7

Hi, I have a MVC web application. I am calling the controller method through the getJSON() method of the jquery. $.getJSON("applicationurl/controllerActionMethod", { parameter1: json, parameter2: jsonGrid, parameter3: value3, parameter4: value4 }, function(jsonResult) { }); Here I am passing the json values into the parameter1 a...

How to fail Ajax.BeginForm in ASP.Net MVC?

Hello, I have Ajax.BeginForm with OnSuccess & OnFailure javascript handlers. How do fail from my controller so that OnFailure is called? Yes, I used to call throw new HttpException(404) and it used to work. But now, I have set a custom error handler that calls Server.ClearError(). Due to this Ajax.BeginForm thinks that no error has o...

Testing the context in asp.net mvc

I got pretty experienced with testing controllers, my question here is though, aren't we supposed to test the data context as well, and how ? I mean, there are a lot of relationships and constraints coming from the DB that simply testing controllers does not cover. On the other hand, testing against the DB is not considered a good prac...

How to make MVC to select proper action in controller

Hi Can somebody explain me one thing. I have two methods in my controller : public ActionResult AddPredefinedTicket(int customerId) {...} and public ActionResult AddPredefinedTicket(int customerId, TicketTypes type, string additionalJsonParameters) {...} (here TicketTypes is enum) I'm tring to make a call with using URL like ...

ASP.NET MVC jQuery autocomplete with url.action helper in a script included in a page.

I have been building my first ASP.NET MVC web app. I have been using the jQuery autocomplete widget in a number of places like this: <head> $("#model").autocomplete({ source: '<%= Url.Action("Model", "AutoComplete") %>' }); </head> The thing is I have this jQuery code in a number of different places through my web app. So i though...

Html.RadioButton group defaulting to 0

Hi A default value of 0 is creeping into a Surveys app I am developing, for no reason that I can see. The problem is as follows: I have a group of Html.RadioButtons that represent the possible values a user can choose to answer a survey question (1 == Not at all, 2 == A little, 3 == A lot). I have used a tinyint datatype, that does n...