asp.net-mvc-2

If(ModelState.IsValid==false) return View(); or View(model); ?

When validation fails, which one I should return? View(); or View(model); ? I notice both work. It is confusing. EDIT: public class MoviesController : Controller { MoviesEntities db = new MoviesEntities(); // // GET: /Movies/ public ActionResult Index() { var movies = from m in db.Movies ...

Which is the correct way to develop a multilingual website on C# .NET MVC2?

We have developed a web application that initially was thought to be only in one language, however now I'm being required to make it multi-lingual, the thing is I don't know where to start. Is there any advice or text you may refer me to? Thank you! ...

C# vs Python: XML Handling/Processing Productivity

Hello, I am planning on writing a medium size web application that will be XML heavy. I will need to do heavy xml processing. When a user requests a webpage the program will fetch the XML from the database then it will process the XML then render the results to the browser. The XML is not big but i will need to make changes to the xml ru...

Menu State - ASP.Net MVC

In my ASP.Net MVC View, I have a menu. The menu consists of a number of Parent Items, with Child Items (anchor tags) underneath. I'm using JQuery to toggle the menu items opened and closed, as the user clicks on them. Unfortunately, once the user clicks onto an anchor tag, and gets sent to another page, the menu state is lost, and th...

TimeoutException on AsyncController in HyperV environment

We are getting a TimeoutException on an MVC AsyncController in our Beta HyperV environment. Everything works fine when debugging locally, but when we deploy to the pre-production environment, we get this error: [TimeoutException: The operation has timed out.] System.Web.Mvc.Async.WrappedAsyncResult`1.End() +129 System.Web.Mvc.Asyn...

Please Help with localizing asp.net mvc application

i would like to add localization to my app... the app is currently not using any kind of localization and the strings are just being injected directly into the views... so i would obviously need to change that.... what I would like is my master page to have two flag icons.. spain and england... and every view could be displayed in either...

Problem using WIF with IIS6

We have a problem using the SessionAuthenticationModule on IIS 6, when trying to access the application, the following exception occures: The data protection operation was unsuccessful. This may have been caused by not having the user profile loaded for the current thread's user context, which may be the case when the thread is imper...

manupulate url in MVC2

On my page I have a lot of textpages and to save some time. I would like to make one controller/Action to handle all this sites. However, this gives me some problems with the URL (I dont want it to say something like http://MySite.com/DynamicPages/TextPages). I figure that I should be able to store all URL's in the database and then get ...

How do I generate a dynamic connection string in Entity Framework 4?

Is it possible to choose a specific database that will be used with the entity framework? At this time, I use the connection string in the Web.Config as database authentication. I have twelve databases, each of them has the same structure and the same stored procedure. There is one database for each client. When a client wants to login...

Model Binding to view in MVC

Hi Team, I am a beginner to MVC and would like to know how I can set by binded model vaule back for viewing. Here is the example. public class DataTypes { public Guid ItemID { get; set; } [Required()] public string Name { get; set; } [Required()] public string Status { get; set; } [Required()] public DataMod...

ASP.NET MVC2 Custom routing with wildcard or free text url

I have a requirement to add specific functionality to an asp.net mvc2 web site to provide addtional SEO capability, as follows: The incoming URL is plain text, perhaps a containing a sentence as follows "http://somesite.com/welcome-to-our-web-site" or "http://somesite.com/cool things/check-out-this-awesome-video" In the MVC pipeline,...

Configuring a simple WCF Service Endpoint in a ASP.NET MVC 2.0

I'm building a simple ASP.NET MVC 2.0 web application. I'd like to serve up a AtomPub endpoint so that I can publish/update content from Windows Live Writer. I originally went down the path of implementing the AtomPub protocol as an Controller with a set of custom ActionResults. That worked until I tried to get authentication working, wh...

ASP.NET MVC TempData in browser cookie

I am trying to use a custom ITempDataProvider provider to store TempData in a browser's cookie instead of session state. However, everything works fine except that I am unable to remove the cookie from the Response stream after reading it. Any ideas? Thanks! public class CookieTempDataProvider : ITempDataProvider { inte...

Entity Framework 4 - check if navigation property collection is empty, without Include() or Load()

In an MVC view, I'm looking for a way to determine if a parent entity's collection of child entities is empty, so I can decide if I need to call a RenderPartial() or not. For a one-to-one I've been using the following: <% if (Model.Book.GenreReference.EntityKey != null) %> {.....} but I'm unsure how to do it in a one-to-many sc...

Bestpractices: StructureMap and ASP.NET MVC 2 - Setter Injection/Contructur Injection in an abstract base Controller

public abstract class ConventionController : Controller { public const int PageSize = 5; public IMappingService MappingService { get; set;} } How do I set up StructureMap to get the Instance of IMappingService? Edit: With the help of Joshua Flanagan I now have the following code: EmployeeController public class EmployeeCon...

navigate on another page in asp.net mvc on button click

I have 2 buttons Edit and Next . I have Action written on controller for the Next button. But how to navigate , where should i have to give action link and its parameters? m using asp.net mvc 2. Is i need to write the JavaScript or JQuery ? ...

MVC Custom Control?

Hello! I am trying to figure out how to use/create a custom control in ASP.NET MVC 2. I created a custom control earlier and compiled it (ccontrol.dll), the control renders a div, textbox and a button + some javascript in order to post a comment on the website. It could be a static aspx page that i wanted to allow my visitors to add a ...

Best way to handle multiple form validation in ASP.NET MVC

Overview I have a payment page where I allow the user to select a payment method, either credit card or check. I have a form for each of these payment methods. I did not want to create a separate page for each of these methods for UI purposes, so I use a [div] for each form and toggle their display with jQuery. Problem Each of the pa...

help using jquery .ajax() method to pass aggregate data to mvc2 action

Hi, I'm trying to use the jquery ajax function to post to a MVC2 controller action, but my parameters include an array of a (simple) custom class and the action is not getting the data correctly. Client: var element1 = { FirstName: 'Raymond', LastName: 'Burr' }; var element2 = { FirstName: 'Johnny', LastName: 'Five' }; var var2 = [el...

Patching Asp.net Mvc2 AntiForgeryToken exception

Some background to my issue: It appears that there is a change/bug in Mvc2 concerning ValidateAntiForgeryTokenAttribute. When upgrading from Mvc1 to Mvc2, users with an active session will receive the following error when they request a page using ValidateAntiForgeryTokenAttribute: Unable to cast object of type 'System.Web.UI.Trip...