What is the difference in behavior of [MaxLength] and [StringLength] attributes?
As far as I can tell (with the exception that [MaxLength] can validate the maximum length of an array) these are identical and somewhat redundant?
I'm updating my old .aspx views with the new Razore view engine. I have a bunch of places where I have code like this:
">Vote Up
Ideally I'd like to do this:
I don't know if this was happening in the PR or Beta, but if I create an extension method on HtmlHelper, it is not recognized in a Razor powered page:
namespace SomeNamespace.Extensions {
public static class HtmlExtensions {
public…
After this question, it makes me comfortable when using async
operations in ASP.NET MVC. So, I wrote two blog posts on that:
My Take on Task-based Asynchronous Programming in C# 5.0 and ASP.NET MVC Web Applications
Asynchronous Database Calls…
I am VERY new to ASP.NET MVC (3) and am having a hard time resolving a build error in Visual Studio:
The type or namespace name 'DbContext' could not be found (are you missing a using directive or an assembly reference?)
using System;
using…
I am trying to make a very basic REST call to my MVC 3 API and the parameters I pass in are not binding to the action method.
Client
var request = new RestRequest(Method.POST);
request.Resource = "Api/Score";
request.RequestFormat =…
I'm getting the following error:
'object' does not contain a definition for 'RatingName'
When you look at the anonymous dynamic type, it clearly does have RatingName.
I realize I can do this with a Tuple, but I would like to understand why the…
I'm using _viewstart.cshtml to automagically assign the same Razor Layout to my views.
It's a dead simple file in the root of my Views folder that looks like this:
@{
Layout = "~/Views/Shared/_Layout.cshtml";
}
This is more DRY than adding the…
I have two controllers, both called AccountController. One of them, lets call it Controller A, is in an Area called Admin and the other, lets call it Controller B, is not in any Area (I guess that means it's in the default Area?). Controller B has…
I am learning about Progressive Enhancement and I have a question about AJAXifying views. In my MVC 3 project I have a layout page, a viewstart page, and two plain views.
The viewstart page is in the root of the Views folder and thus applies to all…
In the default ASP.NET MVC 3 project, layout & partial cshtml files start with an underscore
_viewstart
_Layout
_LogOnPartial
Why this convention, and what is this used for? Do I need to follow this convention?
Does the framework give some…
I have a website that is hosted in a different timezone than the users using the application. In addition to this, users can have a specific timezone. I was wondering how other SO users and applications approach this? The most obvious part is that…
What is the best way to do a redirect in an ActionFilterAttribute. I have an ActionFilterAttribute called IsAuthenticatedAttributeFilter and that checked the value of a session variable. If the variable is false, I want the application to redirect…
I was wondering if it is possible to disable the Required validation attribute in certain controller actions. I am wondering this because on one of my edit forms I do not require the user to enter values for fields that they have already specified…