asp.net-mvc

Can you apply an ActionFilter in ASP.NET-MVC on EVERY action

I want to apply an ActionFilter in ASP.NET MVC to EVERY action I have in my application - on every controller. Is there a way to do this without applying it to every single ActionResult method ? ...

ASP.NET MVC compression options in IIS6

For now I'm stuck with IIS6 for ASP.NET-MVC (as in I cant upgrade to Server 2008 yet). It doesnt seem to know that my RESTful URLS are dynamic files and isn't compressing them. All my old .aspx files are compressed (as seen in Fiddler), but not the '/products/1001' type URLS. Is there any way to get IIS6 to compress my ActionResults in...

How do I perform a secondary action (i.e. calculate fields) in ASP.NET MVC?

I need to do some calculations on an ASP.NET MVC View, an action different than the form submission. I've tried various methods of passing the current Model on to a new controller action via an ActionLink, but the model doesn't appear to be passed. public ActionResult Calculate(MuralProject proj) { ProjectFormRepository db = new Pro...

ASP.NET MVC : Displaying same results on different view

I am developing a learning project with ASP.NET MVC.I have a page that lists logged users's books and I want to display books in two formats like this Normal List --> Display Book Thumbnail, Title,Page count,Author... Detail List ---> Display only Book Title,Author,Page Count in HTML Table format format so I have two view pages Books...

Using default namespaces in .NET MVC for views without using import?

How do you configure the views to able to reference a namespace like System.Web.Mvc without having to do <%@ Import Namespace="System.Web.Mvc" %>? I remember seeing this somewhere but my google skills are failing me at the moment. ...

alternative asp.net MVC view engines

I was wondering if there was a general consensus on the "best" alternative view engine for asp.net MVC. So far I know of Spark, Brail, NHaml but what about others? ...

compile time mvc view checking with msbuild

I've found that in the .csproj for an ASP.NET MVC project there is the following target: <Target Name="AfterBuild" Condition="'$(MvcBuildViews)'=='true'"> <AspNetCompiler VirtualPath="temp" PhysicalPath="$(ProjectDir)\..\$(ProjectName)" /> </Target> This examines the MvcBuildViews bool property in the .csproj which if set to true ...

ASP.NET MVC - Mock a Form Request

I’m just learning ASP.NET MVC and I’m trying to create a mock form request for a unit test. I’m using RhinoMocks. I have looked at the following websites but cannot get these to work. http://blog.maartenballiauw.be/post/2008/03/19/ASPNET-MVC-Testing-issues-Q-and-A.aspx Update: Controller Code: /// <summary> /// Creates a ne...

Securing ASP.NET MVC + Silverlight application

I'm building an application in asp.net mvc. Within this application I want to use the Silverlight multi-file uploader. I'm using the asp.net membership provider that ships with asp.net mvc. My question is how do I ensure security from the asp.net mvc application to the silverlight application? In simple terms: 1. How do I check within t...

Strange behaviour with StructureMap / ASP.MVC / Visual Studio / LinqToSql

I have been using the new MVC framework with StructureMap recently and have had good results overall, however, I keep running into a very strange error that I cannot understand or work out how to resolve. This is my architecture: DBContext - linqToSql data context. IRepository - contract defining data methods. IService - contract def...

Securing a mvc view so only the server can access it

I'm building a .Net MVC app, where I'm using one particular view to generate an internal report. I don't want the users of the site to gain access to this page at all. I've a console app that fires every so often which will scrape some of the details from this page by hitting it's URL. I don't like the idea of having the URL hanging ou...

asp.net mvc renderpartial with null model gets passed the wrong type

I have a page: <%@ Page Inherits="System.Web.Mvc.View<DTOSearchResults>" %> And on it, the following: <% Html.RenderPartial("TaskList", Model.Tasks); %> Here is the DTO object: public class DTOSearchResults { public string SearchTerm { get; set; } public IEnumerable<Task> Tasks { get; set; } and here is the partial: <%@ Cont...

Put current route values/url in form post

In my master page, I have a language dropdown menu. When the user selects a language from the dropdown, a submit sends the currently selected language to the "Translate" method in my controller. After which it should redirect to the url it was before the translation submit so it can show the exact same page, but now in the newly selected...

ASP.NET MVC RC2 - Why can't I use the normal validation options? e.g. RequiredFieldValidator

I'm trying to validate a basic form, can i not use the standard validation controls? Everywhere i'm looking seems to try and use something like the below <%= Html.ValidationSummary() %> <% using (Html.BeginForm()) {%> <fieldset class="fields"> <legend>Create New Contact</legend> <p> <label for="task">Ta...

asp.net mvc newbie question

I recently started to look into asp.net mvc. Here is my issue. Say every page on an application needs a variable set by the user, e.g. a date. If the user starts from url I provide, it is all good as I ask for that date and save it for the session. How can I redirect the user to the first page if they save the some other url (to a diffe...

Accessing HtmlHelper methods within HtmlHelper extension method - ASP.NET MVC RC2

I am trying to build an HtmlHelper extension in ASP.NET MVC RC2. This code worked fine in Preview 5, but does not work anymore in RC2 and I am trying to understand why. Here is the code: public static string EmptyDropDownList(this HtmlHelper htmlHelper, string name, object htmlAttributes) { return htmlHelper.DropDownList(name, new S...

Bypass model binders in asp.net MVC for complex action parameters?

Is there an attribute that can turn off model binding for complex action parameters? My scenario is this: I'm using Linq to SQL but make the generated classes implement interfaces. For example, IUser. Some of my controllers actions accept IUser parameters and some of my views bind IUser models, but I don't want the default model binder ...

ASP.NET MVC - Can I use the commom ASP.NET user's role configuration with MVC?

Hi! Is it possible to use the commom ASP.NET role's configuration on an ASP.NET MVC application? Thanks!! ...

Used Web Platform installer to install the MVC Framework but the MVC template isn't available

I just installed Visual Web Developer and the MVC Framework using the Web Platform installer, I used the ASP.NET option and it says that MVC is installed, but it doen's show up in the templates list when I open a new project. I installed in Windows XP with a limited user (typed the Administrator password to allow the install) I guess th...

Asp .Net MVC with Windows Authtication and SQL Server Role Based Provider

Did anybody make MVC + Windows Auth + SQL Server role based provider work on IIS 7.0? Any pointers will be helpful. ...