asp.net-mvc

MVC Custom ViewModel and auto binding

I have a custom ViewModel defined as : public class SampleFormViewModel { public SampleFormViewModel(SelectList companies, Widget widget) { Companies = companies; Widget = widget; } public SelectList Companies { get; private set; } public Widget Widget { get; private set; } } In my Edit POST handle...

What ASP.NET MVC sample projects exist?

The only sample ASP.NET MVC projects I know about are the following from http://asp.net/mvc. Are there others? Nerddinner.com Stephen Walther's Contact Manager Rob Conery's MVC Storefront CodeCampServer Suteki Shop E-Commerce Application Stephen Walther's Movie Database ...

ELMAH and ASP.NET MVC custom errors not getting logged.

I am trying to use ELMAH for my error logging, and I've tried several others Neither of which seem to log errors when the custom error feature in ASP.NET is enabled I'm using the [HandleError] attribute in all my controllers, at first I thought that was the problem but it isn't just whenever I enable the custom error pages it doesn't l...

How should I namespace my models in ASP.NET MVC? Confused about Nerd Dinner.

I am learning ASP.NET MVC and I like it. However, I am very confused about the right approach to namespacing my models. While dissecting the NerdDinner sample app I noticed that everything in the Models folder belongs to the Models namespace. The data mapping classes, repositories, error rule management, etc., belong to the same namespa...

ASP.NET MVC - redirecting to a Controller/Action by passing some data

I have actions in different controllers that need to check for a some condition before execution. If the condition is not met, I want the user be redirected to another page with instructions on what to do next (the instructions will include a link that the user must follow). For example SendMessage() action is located in the Message co...

How do I display a Image from a database in MVC

I have a data base with images I can get the Image tag to show in the browser but no image Is there an artical or tutorial that will show how to display Image fron database in MVC my tables have GUID userId ...

How to get ELMAH to work with ASP.NET MVC [HandleError] attribute?

I am trying to use ELMAH to log errors in my ASP.NET MVC application, however when I use the [HandleError] attribute on my controllers ELMAH doesn't log any errors when they occur. As I am guessing its because ELMAH only logs unhandled errors and the [HandleError] attribute is handling the error so thus no need to log it. How do I modi...

When to use a Presentation Model in ASP.NET MVC?

Imagine a blog engine in ASP.NET MVC where I want strongly-typed Views. I have a Model for BlogPost and a Model for Comments. A typical page would display a blog post and all of that post's comments. What object should I pass to the View()? Should I create a Presentation Model? Maybe I'm using that term incorrectly, but by that I me...

Hidden Features of ASP.NET MVC (and MvcContrib)

It may be too early for this question, but in keeping with the hidden features meme, I'd be interested in a list of hidden, or rather I guess underutilized, features in the ASP.NET MVC framework and MvcContrib. ...

Better way to make this case REST

Imagine this case: A color has an id. Easy enough. The same color can, depending on the user's language pref, search query and personal preference have a different display name. This display name is not defining, but it needs to be passed on to each page so the user is confronted with the same label every time the color is mentioned. Fu...

Move partial page property to View without code behind

I am refactoring a web app built with previous versions of Asp.Net MVC where all the views have 2 codebehind files each. Also if the views are working correctly I want to begin to remove all the code behind files as most of them are empty. There are few of them that have properties like this in the codebehind: public partial class Lis...

ASP.NET MVC Returning Partial View as a full View Page

I have a number of partial views that are used to render media in different formats (embedded video mainly). I now have a requirement that has me displaying these videos inside an iframe. Is there a way that I can return a minimal HTML page with the partial views embedded in it? ...

Unity Dependency Injection - how to RegisterInstance in .config?

This is a C# Asp.net MVC project. I've currently got the Unity mappings set up in the global.asax.cs. I'd like to move the container setup from code, to the web.config. All has gone fine with my own types, but now I need to translate this line : container.RegisterInstance(System.Web.Security.Membership.Provider); (All the other co...

ASP.NET web site on IIS7 on Vista

Hi, I have dev an MVC app and deployed it to my local IIS as I am using dev server to dev. This is on Vista Ultimate. When i browse the site all the images are not showing and also the login page is displayed. what would be causing the images not to show and also why the login page showed when I have not set up security in web.confi...

asp.net mvc search and edit views

I am considering creating a view that allows for ajax-based search and edit functions. I would appreciate any feedback on the structure I am considering! The structure will consist of A textbox and a search button Submit of the button causes the action Search to be hit, and a partial is returned with - text representation of items fou...

How to create a strongly typed master page using a base controller in ASP.NET MVC

Following the NerdDinners example, I am interested in creating a strongly typed Master Page. In order to achieve this, I use a base controller which retrieves the data for the master page. All other controllers inherit this class. Similarly, I have ViewModels for the master page and any other views. The view ViewModel classes inherit fro...

RememberMe with DotNetOpenId in ASP.NET MVC

Using DotNetOpenAuth 3 in ASP.NET MVC and implementing a RememberMe facility ... I'm finding that even if I set createPersistentCookie to true in FormsAuthentication.RedirectFromLoginPage and FormsAuthentication.SetAuthCookie the user is not remembered once the ASP.NET session times out. If I inspect the cookie I find it is marked as ...

Identity columns and security in a RESTful web application

Question Should autoincremented identity columns have a non-default seed/increment when used in a RESTful web application? Background I'm working on my first ASP.NET MVC application and trying to keep my urls RESTful. There is no separate administrative web site for the application. I use attributes to control who can access what pa...

gadget / widget manager

Does anybody know of any pre-canned gadget/widget management framework (along the lines of iGoogle etc) that I would be able to use on an ASP.NET MVC site (presumably loading divs via jQuery etc)? In particular, I'd rather not write all the selection / location code if there is something decent already available. (I would expect to writ...

Model binding and GET requests?

There are tons of examples for model binding in html forms, but I'm wondering if its possible to, and if so how to, use model binding for ActionLinks/GET requests. So, given the following model public class Lurl { public string Str {get;set;} public char Chr {get;set;} public double Dbl {get;set;} } and the following route (I'm...