Posts tagged asp.net mvc

There are 9 posts for the tag asp.net mvc

Updated Anti-XSRF Validation for ASP.NET MVC 4 RC

In our project, we’ve been using Phil Haack’s method for preventing cross-site request forgeries for JSON posts by inserting the request verification token as a header in the request, and then using a custom ValidateJsonAntiForgeryToken attribute to validate it. And it’s been working just fine. However, with the recent release of ASP.NET 4 MVC RC, it didn’t work anymore. To my initial dismay, it didn’t even compile anymore. Turns out that the method, AntiForg...

Posted by johan on June 05, 2012

Dependency injection in ASP.NET MVC 3 got a lot simpler

In my project of writing my own blog engine, I’m using ASP.NET MVC 3 beta, and I like what they have done to simplify the dependency injection! Let me show you the difference. The MVC 2 way First, I need a registry (that’s just ScructureMap, nothing really to do with MVC). //The most simple registry I could think of public class AlphaRegistry : Registry { public AlphaRegistry() { Scan( x => { x.AssembliesFromApplicationBaseDirectory(); x.With...

Posted by johan on October 30, 2010

I’m gonna build my own blog engine, because it’s never been done before, or maybe I can just do it better!

Today is the first day of my paternity leave, I’ll be home with my little daughter for at least six months. Which is great! But I immediately started to get the itch to write some code. I needed a hobby project. Since I suck at coming up with great ideas, I decided to be a good Jedi and build my own blog engine! Yes, I know, there really is no need for another blog engine. Except that there is. The one I would like to use doesn’t seem to be out there. Also, it seems like a perfect way to try ou...

Posted by johan on October 18, 2010

Getting an ASP.NET 4 application to work on IIS6

Now, for the last 5 months or so, I’ve been involved in a project where we develop an application with ASP.NET MVC on .NET 4 (we started on the beta 2). The main part of this application is hosted on servers running Windows 2008 Server R2 and IIS 7.5. But unfortunately, one part of the application has to be deployed to servers running Windows 2003 Server, and thus IIS 6.0. Turns out, it’s a bit tricky to get .NET 4 working on IIS 6.0. I did the usual stuff, I installed .NET 4 Framework, restar...

Posted by johan on April 13, 2010

Do NOT forget to close() your WCF ServiceClients!

We had a very disturbing problem today. Our client was doing acceptance testing on the application we’re building for them, and had assembled a team of 15 people to do it. The application ran smoothly, until after a few minutes it came to a grinding halt and simply stopped responding. We checked the server, and the CPU was fine. For a while, after a minute or so it went up to 100%. The application is an ASP.NET MVC web client, talking to WCF services, which are talking to an SQL Server. Everyth...

Posted by johan on March 16, 2010

Testing DataAnnotation-based validation in ASP.NET MVC

UPDATE: Aaron Jensen pointed out that this only works for .NET 4. The DataAnnotation.Validator class mentioned in the post does not exist in .NET 3.5, so this method does not work. With .NET Framework 3.5 SP1 came DataAnnotations, and with ASP.NET MVC 2 Preview 1 came built-in support for DataAnnotation validation. This makes basic validation, like required fields, number intervals and so on, very simple. In order to be able to test this validation, though, you have to mimic some of the work th...

Posted by johan on November 18, 2009

Bleeding edge

Starting a new project at work today. For once this project will have to use the latest and greatest technology. We want to use the new Windows Workflow Foundation, which means that we have to use .NET 4 and Visual Studio 2010. We will also use ASP.NET MVC, and since we are using VS2010 beta 2, that means ASP.NET MVC 2 Preview 2. Nice! There are some difficulties, though. For example, we are planning to use StructureMap as for dependency injection, and since MvcContrib has a built-in Controller...

Posted by johan on November 09, 2009

Lifting an ASP.NET MVC 1.0 project to Visual Studio 2010

I have a pet project (several actually, but let’s stick to one of them). It’s called Önskelistemaskinen, and is a web application for keeping track of the wish lists of my family members. It’s build in ASP.NET MVC with a Linq-to-SQL backend (loosely modelled after Rob Conery’s Storefront project), and naturally grossly overdesigned for an application with a target audience of about 10 people. Anyway, I started working on this when the first beta of ASP.NET MVC came out about a year ago, and wi...

Posted by johan on October 21, 2009

ASP.NET MVC + SubSonic + T4 = Sweet!

This post was originally published on http://labs.dropit.se/blogs. I’ve been fiddling around with ASP.NET MVC and SubSonic 3 for a while (as I mentioned in a previous post), and also been learning some cool stuff about T4 Templating. Now Rob Conery has created a very cool Visual Studio template bringing all this together (be sure to watch the video). And it even includes single sign on capabilities with e.g. Google and OpenID! And yeah, lots of ajax with jQuery. I tried using this yesterday,...

Posted by johan on April 03, 2009