asp.net-mvc

DataAnnotations or validate manually in services?

Each time I start working on a new ASP.NET MVC web application, I'm not sure whether or not to use DataAnnotations validation. Something about it feels wrong. For example, let's say I have a UserService which is passed a CreateUserModel from the Create action of the AccountController. To ensure the user always supplies a name, I set the...

building a website supporting many languages/cultures

I am building my first ASP.NET MVC site and this site needs to be in 2 languages. When a user selects a language from the menu, the site would present itself in that language. The content likely will be loaded all from resource files. Can I respond to a change in the culture definition at runtime so it load the correct resource file? ...

ASP.net MVC Directory Browsing

Hi All, Im adding the ability to upload images to my ASP.net mvc application. Basically the user selects an image and I upload it to an Images folder which i've created in my solution folder structure. This works great and the image uploads to the images folder. The problem I have is now displaying the image back to the browser. My ques...

.net mvc keybindings poster

Hi all, I've been looking for some asp.net mvc keybinding posters but can only seem to find ones for VS 2010 which dont include any MVC specific things. Is there any out there? Or what would be the easiest way to make one for myself? I'm using resharper as well but that also doesnt seem to have a specific poster for mvc. ...

How to build Facebook style Ajax site

I understand that the title is a little vague and all-encompassing, so please let me try to narrow it down. What I would like is advice on how to develop a mostly Ajax website, where portions of the UI are asynchronously loaded. Here's the catch: I'd like to have the browser back/forward buttons work intuitively - something that Faceboo...

2010 Beginners guide to fluent nHibernate

I need some tutorials on how to get started with nHibernate and Fluent nHibernate. I'm coming from an Entity Framework background (which seems easier to use). I've tried sites like http://www.summerofnhibernate.com/ to get a grasp on nHibernate itself, but it seems outdated. I'd like to generate a mapping of my database tables (al la En...

Update A Partial View From Another Partial View - ASP.NET MVC2

I want to have two partial views, one for SEARCH and one for SEARCHRESULTS. I want to update SEARCHRESULTS when the "Search" Button is clicked on the SEARCH partial view form. SEARCHRESULTS needs to have the form data fed to it from the SEARCH partial view. I'm not totally sure how to go about this. Can I update the SEARCHRESULTS par...

Server error in '/' Application in Mvc Music Store ASP.Net MVC Sample Ported to Mono

I'm currently porting the Mvc Music Store example to Mono, and it going very well, but I've run into a snag with a trailing slash on one of the routes. On the master page is the following link <a href="/Store/">Store</a> When I run the application and navigate to /Store/ I get the following error Server Error in '/' Application The ...

ASP.NET MVC UpdateModel for foreign key dropdownlist

Using MVC 1.0 I have the following custom form view model public class NoteFormViewModel { // Properties public Note Note { get; private set; } public SelectList PrivacyOptions { get; private set; } // Constructor public NoteFormViewModel(Note note) { SharePermissionsRepository sharePermissionsRepository...

Extend Url Route to apply Url Encoding for each parameter

Hi guys, I am facing a problem that one of my fields need to be shown in the url contains special character (/, \, :). The stupid way to handle this generate action links by using UrlEncode(). Then UrlDecode is used before consuming in controller. But I think it really stupid because too many places need to be adapted. So, my problem ...

How to avoid placing domain logic in controller?

On PRO ASP.NET MVC book: It is certainly possible to put domain logic into a controller, even though you shouldn’t, just because it seems expedient at some pressured moment. Just a contrived example, if the application doesn't allow negative order, where to put the changing of quantity to 1? If we follow the principle that d...

jQuery getJson() not working with in ASP.NET MVC

I want to use jQuery to make a simple call to my MVC controller. I was able to debug the server side, meaning the controller picked up the ajax call and return the information requested. But the client side is never updated after server side returns. When I use FireBug to debug the script, the client side is stuck on event.isImmediatePro...

problem with adding jQuery to ASP.NET MVC application

I've a problem with adding jQuery to an ASP.NET MVC application. I add jquery to Site.Master like that: <script src="../../Scripts/jquery-1.4.1.js" type="text/javascript"></script> In Visual Studio 2010 this is o.k. - now I publish a application to a web server (IIS 7) an a Folder like: h ttp://localhost/AnApplication When calling...

Adding command column to a jqGrid in Asp.Net MVC

Dearest All, I hope you have a good morning. I'd like to use jqGrid in my Asp.Net app. So far, I've been producing an html table and converting it to a grid, but I'd like to try a better approach: loading the data via an AJAX call as it's supposed with the grid. I found out how to fetch data, but I'd like to have the "Edit" and "Delete...

How do you find out the URL of HTTP POST request in the ActionResult

Very simple question but I am unable to find an answer, I have a MVC 2 app in C# I have a ActionResult the accept's HTTP POST's How do I find out the URl of any posts to my ActionResult. Thanks, ...

MVC Authentication bypass for a single controller/action

Hi, I am using MVC with forms authentication and i need authentication bypass for one of my controllers, is it possible to bypass authentication for Cotroller(s)/Action(s). I have been through http://stackoverflow.com/questions/1816625/asp-net-mvc-forms-authentication-and-unauthenticated-controller-actions , but i dont want to restrict ...

Define relation between 2 tables using ActiveRecord and ASP.net mvc

I am tring to define a one to one relation between 2 tables using active record. I have a table Device and a table DeviceLocation. This is the code I use in DeviceLocation to define the relation: [PrimaryKey(PrimaryKeyType.Foreign)] public int DeviceID { get { return _deviceID; } set { _deviceID =...

How do I set the max number of items visible in a SELECT drop down?

Hi, I have a drop down list of around 30 items and I want to only show 8 items and then the drop down should scroll. I'm using MVC2 in VS2010 <%= Html.DropDownListFor(d => d.Thing.ThingID, Model.Things, new { style = "width: 200px", rows = 10 })%> ...

.NET MVC Explicit Views

Hey, one more newbie here, just playing around with .NET MVC. My main task is to have a few semi-static pages on URLs like: /about/ /about/contacts/ /about/jobs/ I'm using a controller for that called Static and have the following route attached: routes.MapRoute( "About", "about/{id}", new { controller = "Static", action = "In...

Ways of implementing Unit of Work in ASP.NET MVC

I'm currently researching how to add the Unit of Work pattern to my existing ASP.NET MVC application that uses NHibernate. I'm seeing a lot of variety in the various implementations and I'm having trouble determining which methods will work best in a given situation. To help, I thought I would ask the Stack Overflow community to list t...