asp.net-mvc

ASP.NET Charting Control no longer working with .NET 4

I've just upgraded to .NET 4 and my ASP.NET Chart Control no longer displays. For .NET 3.5, the HTML produced by the control used to look like this: <img id="20_Chart" src="/ChartImg.axd?i=chart_5f6a8fd179a246a5a0f4f44fcd7d5e03_0.png&amp;g=16eb7881335e47dcba16fdfd8339ba1a" alt="" style="height:300px;width:300px;border-width:0px;" /> ...

How do I stop IIS7 from putting out its own 404 before my MVC app gets a chance to handle it?

I have an ASP.NET MVC 2 application, which has an Application_Error event handler in global.asax. In this, I'm detecting the case where the Exception type is HttpException and the HTTP code is 404, and redirecting to my own 404-handling page. This works fine on my Cassini development server, but now I'm trying to move it over to my prod...

Using a .MDF SQL Server Database with ASP.NET Versus Using SQL Server

I'm currently writing a website in ASP.NET MVC, and my database (which doesn't have any data in it yet, it only has the correct tables) uses SQL Server 2008, which I have installed on my development machine. I connect to the database out of my application by using the Server Explorer, followed by LINQ to SQL mapping. Once I finish deve...

How can I perform action from ASP.NET MVC with different user credentials?

Hopefully this explanation will make sense, but what is the best way (if it is even possible) to pass along user credentials to preform a specific application from an ASP.NET MVC application. Currently I am working on trying to create directories on another server, we can't do this using the generic credentials that the application is ru...

textbox not getting refreshed

i am doing an ajax call and i refresh a partial view. Inside the partial view i have this: <%=Html.TextBox("instance.Id", Model.Id)%> when i put a breakpoint here over Model.Id it has a number in it but after the ajax refresh is done the textbox just shows up with a 0. When i do a full browser refresh, the correct number shows up in ...

Custom MVC Error Message Localization

Hi there, I want to localize my error messages on my model using attributes, such as RequiredAttribute and RangeAttribute. I'm using ASP.NET MVC2 in Visual Studio 2010. This is really easy if my localized resources were in resx resource files... using ErrorMessageResourceName and ErrorMessageResourceType... however, I need to integrate...

MVC 2 Catch-All for connection string missing or connect failure

In the event my project is deployed with an incorrect, incomplete or missing connection string i'd like an application startup check for db connectivity, and if there is none, direct all requests to a DatabaseConnectionError page of some sort, what are my options? I don't think there's a specific http error code that would fit this error...

How do I dynamically tell a .NET MVC application which datasource to point to?

I'm beginning a port of an existing ColdFusion application to .NET MVC and one of the first issues I'm running into is that in ColdFusion we use the fact that you can define multiple datasources and access them in a dynamic way so that a particular user can be pointed at a particular database. To give an example, I might have two databa...

Exclude ID property from xVal validation

Can I exclude the valudation rule for the ID property? Right now I get the following validationerror message when I submit the form: The Id field is required. ...

Unable to connect to UNC share with WindowsIdentity.Impersonate, but works fine using LogonUser

Hopefully I'm not missing something obvious here, but I have a class that needs to create some directories on a UNC share and then move files to the new directory. When we connect using LogonUser things work fine with no errors, but when we try and use the user indicated by Integrated Windows authentication we run into problems. Here's s...

Will an ASP.NET MVC 2 app build with the .NET 4.0 RC and VS2010 RC run on a prod server with the .NET 4 RTM release?

I have an MVC2 app I developed with the VS2010 RC and the .NET 4.0 RC. My production server and my client's production server have .NET 4.0 RC. Can the RTM of .NET 4.0 on a server support an app developed with the RC technologies? What about the other way around? Can I use VS2010 RTM and deploy an app to production if the prod server i...

ASP.NET MVC: How to validate an Ajax form with a specified UpdateTargetID?

I'm trying to figure out how to show validation errors after a user submits an Ajax form that has its UpdateTargetID property set. I'm stumped on how to update the Ajax form with the validation errors without returning the Create PartialView into the results div. If the form is valid, then it should return the Records PartialView. Crea...

TempData and ViewData not rendering in a deployed ASP MVC app

I use TempData and ViewData to display messages for an asp mvc application. They are part of the Site Master. For some reason, neither TempData or ViewData are showing any information. They do work as expected in the development environment but not in production. Any ideas of what setting I need to be looking at? The code is like this:...

Error in ASP.NET MVC 2 View after Upgrading from ASP.NET 4.0 RC to RTM

In my View, I am trying to loop through a list in a LINQ object that as part of my View Model. This worked fine earlier today with the VS2010 RC and the .NET 4.0 RC. <% if (Model.User.RoleList.Count > 0 ) { %> <% foreach (var role in Model.User.RoleList) { %> <%: role.Name %><br /> <% } %> <% } else { %> <em>None</...

Updating Model with entity collection

There are a group of entities named Book and Magazine which inherits from the abstract class PublishedItem. PublishedItem have these properties: ID, Name, Publisher, List of Authors, List of Genres. The Book entity has the ISBN property and the Magazine entity has the ISSN property. I just want to ask how I can update the book's or maga...

Linq to Entities and POCO foreign key relations mapping (1 to 0..1) problem

For my ASP.NET MVC 2 application I use Entity Framework 1.0 as my data access layer (repository). But I decided I want to return POCO. For the first time I have encountered a problem when I wanted to get a list of Brands with their optional logos. Here's what I did: public IQueryable<Model.Products.Brand> GetAll() { IQueryab...

ASP.NET MVC Storing data retrieved from View temporary

How do I store a list of data that is submitted to a controller for about an hour in memory, so I can call another action and pull this data? Reason for this: I need to show a demo application, no time to write up the database logic. So I want to simulate a database with a list of objects. For eg. I send a list of Persons { FirstName, ...

Conditional Regular Expression testing of a CSV

I am doing some client side validation in ASP.NET MVC and I found myself trying to do conditional validation on a set of items (ie, if the checkbox is checked then validate and visa versa). This was problematic, to say the least. To get around this, I figured that I could "cheat" by having a hidden element that would contain all of the ...

In ASP.NET MVC, how do I find out what controller and action is handling a particular URL?

Simple question! I'm not asking how to configure routes. I'm asking, given a particular URL, how do I find out for sure which controller action it is being routed to. (Perhaps in the context of a large application with many controllers and a complex route registry.) ...

Activate jQuery accordion section with validation errors

I am using xVal for client validation in an ASP.NET MVC application. Since I have too many fields in one of the forms, I split it into sections and used jQuery accordion to display one section at the same time. Is there a way to activate the accordion section which contains validation errors when the user clicks submit? ...