asp.net-mvc

Invalidate portions of the asp.net mvc output cache - with varying levels of granularity

I'm a little confused about the granularity offered by the HttpResponse.RemoveOutputCacheItem() call. I'm interested in performing some output caching on dynamically-generated images, and would like to vary the output cache using at least to paramaters (let's call them 'id' and 'size' for argument's sake). So, for example: /Image/User...

Routing is finding the controller in my areas, but not the views

I'm trying to use Maarten Balliauw's Domain Route class to map sub-domains to the areas in an MVC2 app so that I have URLs like: http://admin.mydomain.com/home/index instead of: http://mydomain.com/admin/home/index So far, I've only had partial success. Execution is being routed to the correct controller in the correct area, but it...

MVC2 ViewModel Binding

How do I get properties in my BLL passed down to a ModeView. For example, I have this class in a separate Class Library: [MetadataType(typeof(PersonMetaData))] public partial class Person { [Bind(Include = "PersonId,DepartmentId,FirstName,LastName,Active,DateAdded,DateDeleted")] public class PersonMetaData { ...

Proper structuring of Lucene.Net usage in an ASP.NET MVC site

I'm building an ASP.NET MVC site where I plan to use Lucene.Net. I've envisioned a way to structure the usage of Lucene, but not sure whether my planned architecture is OK and efficient. My Plan: On Application_Start event in Global.asax: I check for the existence of the index on the file system - if it doesn't exist, I create it an...

MVC Model Binding and DropDown List

I have a Person class displayed below. In the view I need to display its properties, plus the DepartmentName that exists in a different Table. DepartmentId in the class below is a Foreign Key. I am using Linq to SQL. I am also display my PersonRepository and Controller code below. I need to display the DepartmentName in the Index Vi...

How to manage significant functionality differences between user types in ASP.NET MVC2

I think I may have made a mess of my controllers. I have a fairly simple site that allows users of type "Staff" or "Client" to view Projects. Staff have access to all projects, can add and delete them, add and delete users, assign clients permission to projects, etc. As it stands this means I have a UserController and ProjectController,...

ADO.net reference loading in Property

I have the following problem. An object has an address, and this address has a country. To fill a dropdownlist with the available countries in the DB I use a property in the partial class of the object: public string CountryID { get { return this.Addresses.Countries != null ? this.Addresses.Countries.ID.ToString() : null; } ...

Attribute 'DisplayColumn' is not valid on this declaration type. It is only valid on 'class' declarations.

Just wondering why I get compile time error : "Attribute 'DisplayColumn' is not valid on this declaration type. It is only valid on 'class' declarations." using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.ComponentModel.DataAnnotations; namespace MyApplication.Models.DataAnnotations { ...

VS 2008 crashes after Anti-XSS added

Hello I'm using visual studio 2008 with asp.net mvc 2. I need anti xss library to santitize an input which is generated by rich text editor (lightweight RTE). I want to use AntiXss.GetSafeHtmlFragment(input); function. the problem is that VS 2008 crashes after I reference anti xss dll (it works fine in the first time but than it crashe...

What can asp.net *WebForms* developers expect in future?

Although it is said that Webforms and MVC are treated equal I am in doubt. Most new stuff seems to be happening around MVC. It's not about technical aspects, more a personal question. So what to do? Keep with Webforms and set focus on Sharepoint (still Webforms)? Keep with Webforms and simply trust Microsoft and the future of Webform...

Asp.net MVC seems to be binding a List<string> property of my model incorrectly in certain environments

We have developed an asp.net mvc application which is an internal application. Our web app is accessed through other websites/applications on our companies network. One of the applications is a windows app that displays the site through a web browser in its application. I've been told by the developers of that application that it uses...

C# Create an Auth Token from Guid combined with 40Char Hex string (UUID)

I am writing an asp.net MVC app that drives an IPhone application. I want the Iphone to send me its UUID looks like this: 2b6f0cc904d137be2e1730235f5664094b831186 On the server I want to generate a Guid: 466853EB-157D-4795-B4D4-32658D85A0E0 On both the Iphone and the Server I need a simple aglorithm to combine these 2 values ...

How do I keep field values in the ASP.NET MVC form if it has been invalidated?

I have a form that is going through some validation before sending an e-mail. I have tried using this for validation, where the method ValidateInput sets the ModelState depending on the input: [HttpPost] public ActionResult Create(FormCollection collection) { ValidateInput(collection); if (ModelState.IsValid == false) return Vi...

Fill textboxes based upon current Dropdownlist (database items) selection (asp.NET MVC)

I have a dropdown box in my view which is populated with objects from database. Now what I want to do is, based upon selection in the Dropdown fill various textboxes with property values of the object selected in the dropdownlist. There are numerous examples where you copy the selected dropdown value in the textbox using JQuery / JavaS...

ASP.NET MVC/IIS 7: Creating dynamic websites (subdomains) with a button click

I'm working on a community forum script, and I want to give every one an opportunity to create their own community forum for free. So let's say I have the following domain: www.forum.com Bob wants to create his forum, he signs up, picks a username ("bob") and gets his own forum instantly: bob.forum.com There are the things that need ...

Why does this code changes location as I need it to

Hi, I have a weird question. I have been writing a code to change the view by a <select>'s onchange like this: <% Html.BeginForm(); %> <label for="id" >Automat:</label> <%= Html.DropDownList("id", Model as SelectList, new { @onchange = "window.location.href = document.getElementById('id').options[document.getElementById('id').selectedIn...

How to structure CAPTCHA validation architecture for an ASP.NET MVC site?

I'm writing an ASP.NET MVC site where I want to display a CAPTCHA when content that a user submits fails my Akismet spam check. I know how to display the CAPTCHA, but I'm having trouble imagining and planning the architecture for this. Here's what I'm currently thinking: User submits content via HTTP POST The action that handles the su...

MVC .NET 4.0 : Image Links

I was recently introduced to the HTMLhelper class....along with MVC in general. Does MVC, or the HtmlHelper class give any alternates for image links...and static links? For example, if I want to display an image on a webpage, do I still have to do the traditional href tag? I.e. <img src='/Content/Images/mypic.jpg' /> or is there...

Are there any action filters in your project you feel are a must-have?

I'm still not totally clear on why I would need to build custom action filters. Maybe a couple examples would help. Are there any action filters in your project that you feel are a must-have? Maybe even so important that you re-use them across all your MVC projects? ...

New suggestions for error handling in ASP.NET MVC 2

There's been a lot of examples on error handling here at SO since MVC 1 first came out and on specifically 404 error handling but since a lot of stuff changed with version 2 and new techniques emerged I would like to ask this question of what is the latest, preferably most optimal way of handling 404 (and other) errors in ASP.NET MVC 2. ...