asp.net-mvc

Is it possible to create ASP.NET MVC applications in VS 2010 B1?

Is it possible to create ASP.NET MVC applications in VS 2010? What should I do to enable 'Create View', 'Create Controller' magic? ...

Calling FilterAttribute's OnActionExecuting before BaseController's OnActionExecuting

I have a BaseController in which I put in some data in the ViewData collection by overriding OnActionExecuting. Now i have an Action in a ChildController that doesn't need that view data. For that purpose I created an DontPopulateViewData ActionFilterAttribute that sets a bool on the BaseController that prevents the BaseController from...

Where can I find a dead-simple explanation of MVC?

At my company we're about to build a new site using ASP.NET MVC. My boss (marketing guy) would like to know some more about the technology so I've tried to find a really good, simple and pedagogical presentation of the MVC concept without any luck. Most of them require quite a lot of basic knowledge in programming. Any suggestions for a...

ASP MVC Areas and ActionLink

I'm working on a new project where I want to use Phil Haack Areas (1) idea + Steve Sanderson's tweak (2). I have a simple root view with an action link to a view an area (Foo). The URL that is generated has the proper area, but it appends the root controller (Bar) at the end. Here's my root view code: <asp:Content ID="Content2" Conte...

Viewmodel security in asp.net mvc

Is there a difference in terms of security between these two models to be given to View? Ie. in the second example can a webuser/hacker access the methods in any way? public class ObjectViewModel { public PropertyA {get;set;} public PropertyB {get;set;} public PropertyC {get;set;} } public class ObjectViewModel2 { ...

My action controller code looks amateurish

First post time, I've been playing around with MVC abit... I have a view which has multiple input fields, some of these fields can be blank on post. The action method inside the controller for the post looks something like this public ActionResult Filter(int? id, string firstName, string lastName, bool? isMember) I've been using the...

how to create google sitemap for mvc site?

Hello there, I was wondering if anyone has done this yet or has any examples on how to create a Google Sitemap for an MVC website. Any help or example would be appreciated. Im talking about this: https://www.google.com/webmasters/tools/docs/en/protocol.html ...

How can I disable session state in ASP.NET MVC?

I would like to have a very lightweight ASP.NET MVC site which includes removing as many of the usual HttpModules as possible and disabling session state. However when I try to do this, I get the following error: The SessionStateTempDataProvider requires SessionState to be enabled. I've disabled session state in web.config: <sessionSt...

Asp .Net MVC RedirectToAction with absolute URL

I have written an Asp .Net MVC applicaton that runs inside an IFrame. When one of my controller methods returns RedirectToAction(), I want the top browser URL to redirect to the address, not just my IFrame. How would I go about doing this? Because I am running inside another site, I will need to pass an absolute URL to the browser i.e. '...

Can System.Web.MVC.UpdateModel update EF Navigation Properties?

If I have 2 tables in my database: Foo and bar. Foo is identified by FooId and Bar is identifier by BarId. A Bar can have 0 to many Foos therefore Foo has BarId as a foreign key. I have a model which represents this and an view which can be used to edit a Foo and select (from a dropdown) the associated Bar. Given the following method o...

How to Integrate LinqToSql with Metadata Annotations

I'm just getting started on a new MVC project, and like a good boy I am trying to defer going to the DB for as long as possible. Here's the scoop: I'm planning on using the ComponentModel.DataAnnotations decorations. I'm also planning on using LinqToSql Is is possible to write a unit test against the DataAnnotations metadata classes?...

Linking JavaScript Libraries in User Controls

I have been using ASP.NET MVC for six months or so and have been checking out the Nerd Dinner example created by those Microsoft guys. One thing I noticed they did when enabling AJAX to RSVP for a dinner, is put the JavaScript references in the User Control being used for RSVPing. (FILE: RSVPStatus.ascx) <%@ Control Language="C#" In...

Find the atrributes on an action from the ViewEngine in ASP.NET MVC

I've got a custom ViewEngine and I want to modify the master page used depending on if the requested action has an Authorize attribute filter. So far I'm just using reflection like this: var method = controllerContext.Controller.GetType().GetMethod(viewName, BindingFlags.Instance | BindingFlags.Public | BindingFlags.IgnoreCase); if (me...

Can I access Resources file from a View in MVC ?

Hi folks, I want to populate dropdownlist with values stored in a resource file. What's the best approach for this? I can create a SelectList and push it in Model in which case dropdown would be populated automatically. But can I access resource file from a View ? If yes, should I? ...

A public open source HtmlHelper repository for sharing "controls"

After using the MVC framework for a little while now I must say I love it, but in my opinion there has always been one thing that poops on the MVC party cake. The lack of good, reusable and portable "controls". This is where the HtmlHelpers should kick in. After reading this blog post I started thinking about what exactly I’m expectin...

How to keep a parameter from url after redirect to login.aspx

I have the following route: {language}/{controller}.mvc/{action}/{id} Once a user has choosen the language it is then maintained in the route-value language. http://localhost%3A4000/de/Account.mvc/Register I have a problem if a user hits a page that needs auhtorization. He ist then redirected to http://localhost%3A4000/Account.mvc/Lo...

ASP.NET MVC DropDownLists

Hi all <%= Html.DropDownList("ServiceId", new SelectList(Model.Services, "Id", "Name"),"-- Please Select --")%> Is there a way to give the please select item a value of 0 or -1? Thanks ...

HtmlHelper extension method vs partial view?

I curious when it's recommended to use HtmlHelper extension method and when to use partial view? They seem to be equally eligible in many cases. ...

ASP.net MVC RouteLink and optional routeValues

I'm trying to figure out how to conditionally set a routeValue which is optional. I have <%= Html.RouteLink("<<<","Products",new { page=(Model.Products.PageIndex) }) %> If a visitor clicks on a "category" I only show products of that category, but if there is no "category" I show all products. These 2 URLs would be valid: /Product...

Provide explicit view names when unit testing a controller action?

Stephen Walther recommends that you should provide explicit view names when you want to unit-test them. I definitely want to test them, but I'm curious whether or not this recommendation is still valid with the release of 1.0. In the NerdDinner tutorial the tests just check if the viewResult is null. They don't explicitly specify the ...