asp.net-mvc-2

I'm about to start using ASP.NET MVC2 for my web application.

I have a pretty big web application that I created last year using ASP.NET webforms. It has two parts: Admin and Client (each one a project inside a single solution). Admin logs in as you would expect and manages the clients. Clients log in and manage themselves. SQL Server back end. It relies heavily on MasterPages and LINQ. It ha...

Default resource for data annotations in ASP.NET MVC

There's a way to set the default resource to the data annotations validations? I don't wanna make something like this: [Required(ErrorMessage="Name required.", ErrorMessageResourceType=typeof(CustomDataAnnotationsResources)] public string Name { get; set; } I would like something like this: Global.asax DataAnnotations.DefaultResour...

Is ASP.NET MVC definition of an AJAX success to narrow? how do i deal with other status codes?

I am using Ajax.BeginForm(... in asp.net MVC 2.0 I would like to return HTTP status codes from my controller. For example: 400 (validation error) 200 (if everything is OK) I would like to use new AjaxOptions{UpdateTargetID="ajax-form", OnSuccess="...", OnFailure="..."} to handle these scenarios, however If I return a statuscode ...

ASP.NET MVC2 Linq Where Clause using StartsWith

I have a few filters on my view, the first one is list by first name, last name and company name when one of these options are selected the user can then select a, b, c ... x, y, z to show only people starting with the selected letter. if (collection["Filter"] == "2") { presentations = presentations.Where(x => x.Person.FirstName.Sta...

Where are the account data of a new asp.net mvc web application put ?

If you create a new ASP.NET MVC 2 Web Application and run it, you can register new users and logon. But I can not find where does those account data are put. Database? Local files? Or session??? ...

After HttpPost, returning a View (ActionResult) when Model is not valid, the response has content type of application/json

I'm running into a strange issue in more than one page of my ASP.NET MVC site. When I POST a form and the Model is NOT valid, I try to return the same view so that I can see the errors - however, instead of the page getting reloaded, I get a pop-up download box that says that the file is in "application/json" format. As you can see fro...

mocking Request.Files to test empty file upload

I am trying to unittest a file upload but seem to be missing something. The controller contains this fairly standard block in the httpPost handler: foreach (string file in Request.Files) { var postedFile = Request.Files[file] as HttpPostedFileBase; if (postedFile.ContentLength == 0) continue; var fileName = "~/Uplo...

How does RedirectToRoute affect SEO?

So I have my domain - www.mycatchyname.com, and its basically a single page site that has one purpose, so I've used RedirectToRoute on the root controller/action to go straight to www.mycatchyname.com/seo-keyword. So www.mycatchyname.com/seo-keyword is basically the homepage. How does Google see this? People searching for what my site i...

Why am I getting App_GlobalResources assembly generated? (Error = CS0433)

I'm working on a ASP.NET MVC2 project, for which I have configured the localisation as follows ... I have a separate Resources assembly, containing all my resx files. The settings for each resx file are... Build Action = Embedded Resource Copy to Output Directory = Do not copy Custom Tool = PublicResXFileCodeG...

How to prevent validation of relationships in model binder?

An example, if I have a class named Order with a field referencing a Customer, and then an Order form with an drop down list (<%= Html.DropDownListFor(e => e.Customer.ID, new SelectList(...)) %>) for setting the Customer the model binder will create an empty Customer with only the ID set. This works fine with NHibernate but when validati...

Funky Sql Generated using SubSonic Simple Repository, LINQ and ASP.NET MVC

I have the following code: if (collection["Filter"] == "2") { presentations = presentations.Where(x => x.Speaker.FirstName.StartsWith("B")). OrderBy(x => x.Speaker.FirstName); } this generates the following sql: SELECT [t0].[Description], [t0].[EventId], [t0].[Id], [t0].[PresentedOn], [t0].[Slug], [t0].[SpeakerId], ...

Area of responsibilities between Controller and Repository in ASP.Net MVC2

I'm trying to get an understanding of how to structure an ASP.Net MVC2 Web App using repositories. A lot of examples, tutorials and books I have read structure the App like so: public interface IProductsRepository { IQueryable<Product> Products { get; } } public class SqlProductsRepository : IProductsRepository { public Table<...

DotNetOpenId claimsResponse always Null

Hi, I found a several post about this topic. But I'm not able to find a solution. So. I set the ClaimRequest in the request: IAuthenticationRequest request = openid.CreateRequest( Identifier.Parse(id),Realm.AutoDetect); // Require some additional data request.AddExt...

ScaffoldColumn(false) is not detected when generating MVC 2 View in VS2010

If I understand the [ScaffoldColumn(false)] attribute correctly, I should be able to decorate a variable with this and then, when I create a strongly-typed Edit view, that field will show up as hidden text and NOT a Label/Textbox pair. I am using entity framework and then adding a partial class with an inner metadata class like so: [Me...

Model binding for a ViewModel containing multiple objects

Hey everyone, I have a strongly typed view of type ProductListingViewModel which in turn contains a ProductViewModel. (both custom view models). I have some form elements on my page and these are created like so: <%: Html.DropDownListFor(m => m.ProductViewModel.CategoryId, Model.Categories)%> which generates the HTML: <select name...

fill html.textbox upon html.dropdownlist onchange in asp.net mvc

Hi Guys, I'm new to asp.net mvc... & need help for my below question: When the form loads my Country dropdownlist has some values. I want when the user selects a value from the dropdown list it should go back to the controller and makes a call to the database to retrive the CountryCode value based on the Country selected. How do I s...

ASP.NET MVC 2: Data Annotation or Template: way to associate a DDL to its Model.data option list?

Summary: If you use ASP.NET MVC 2's templates to render a DropDownList, how would you access the list of options if they are stored in the top level View's Model.property? Also, is there some [DataAnnotation] way to associate this list? Links to examples would be very helpful. Background: In ASP.NET MVC 2, you can create a custom cl...

Html Encode when data is inputed? Or Outputed or both?

Hi Just wondering should I encode all the data before I put in to the database or when I display it to the user? Or Both. Right now I do it when I display to the user. I am using asp.net mvc 2.0 so I usually just make everything <%: %> what does encoding for me. I am not sure with both though it might be a little extreme to do it to t...

The view 'Save' or its master was not found in IIS. Works in Cassini.

I have an MVC app with a Partial View whose form action is /Content/Items/Save. There is no view called "Save" but the ItemsController.Save action calls Edit or Create as needed. These methods both return RedirectToAction("Index") upon success. In Visual Studio, this all works fine. In IIS, I get the above message when submitting fro...

All new actions on controller are coming up 404 in my existing controller and new ones.

All of a sudden, new actions on all my controllers are coming up with 404 errors. The actions that were already there work fine. For instance this controller method works: public ActionResult AddItem() { return View(); } But this one does not: public ActionResult Bob() { return View(); } Both Views/Tools/AddItem.aspx and V...