## Find projects which are missing in your "All Projects" solution

Do you use a Visual Studio solution which contains all of your projects to do daily builds? If you have lots of projects and if many people are involved it’s very likely that somebody forgets to add his project to this solution.

This small program helps you by showing you all csproj-files that are not part of your solution file!

class Program
{
static void Main(string[] args)
{
// Parameters
string baseFolder = @"C:\path\to\solution\";
string slnFile = "AllProjects.sln";
string outputFile = "MissingProjects.txt";

string slnContent = File.ReadAllText(Path.Combine(baseFolder, slnFile));

string[] projectFiles = Directory.GetFiles(baseFolder, "*.csproj", SearchOption.AllDirectories);

List<string> missingProjects = projectFiles
.Where(fullPath => slnContent.IndexOf(fullPath.Replace(baseFolder, ""), StringComparison.OrdinalIgnoreCase) < 0)
.ToList();

File.WriteAllLines(outputFile, missingProjects);

Console.WriteLine("Projects missing in solution: " + missingProjects.Count);
Console.WriteLine("Details: " + outputFile);
}
}

## Feature Folders: Controllers and Views

The first step in our process to a better folder structure for our MVC projects is to make sure, MVC can resolve our Controllers and Views. This is our target structure:

• (Project Root)
• Areas
• (AreaName)
• (FeatureName)
• (FeatureName)Controller.cs
• Index.cshtml
• Edit.cshtml
• … (other features)
• Shared
• … (area specific shared views like EditorTemplates, Layout-pages, …)
• … (other areas)
• Shared
• … (area independent shared views like EditorTemplates, Layout-pages, …)
• Features
• (Feature2Name)
• (Feature2Name)Controller.cs
• Index.cshtml
• Edit.cshtml
• … (other features)
• Shared
• … (feature independent shared views like EditorTemplates, Layout-pages, …)

Of course, if you don’t want to use “areas” you only need the “Features” folder in your project. This also means, that if you move to this new structure, you can completely remove the old “Controllers” and “Views” folders.

## Introducing the ASP.NET MVC “Feature Folders” Project Structure

### What’s the problem with the default ASP.NET MVC folder structure?

Which of these requirements is more common?

• Change something in every view, controller or model of your project
• Add a new field to your model X, show this field to the user, make it editable, the value must be validated against some fancy rules, …

I guess we are on the same page if we see the second one as more common. I would go as far as to say that if you have the first requirement you’re either working on a major relaunch or you’re not using layout pages, css, abstract classes, [insert random reusability gadget here] correctly.

## Moving my BlogEngine.NET blog to Microsoft Azure

I thought, after 5 years since my last post it might be time to write a new one! But that’s not so easy! When you login to the backend after such a long time, everything feels just wrong: The design is ugly, the blog engine is outdated, I’m not sure if my hosting provider still is the best choice for me and I don’t like my domain anymore! So, instead of just writing a post about something, I decided to change all of these things first and tell you about this process!

## Meet me @ BASTA! Spring 2009

Hello everyone!

Next week, I will attend the biggest German .NET conference BASTA! Spring 2009. Feel free to contact me, if you’d like to chat with me “offline” there!

### What’s next on my blog?

I’m working on an ASP.Net MVC application right now and I plan to post about some of the techniques I’ve used, so expect to read from me after the conference!

Christian Weiss

## Testable and reusable cookie access with ASP.Net MVC RC

All good things come in threes, so I’m writing another post about how to access cookie or sessions. I got inspired by a comment from Chris Marisic, who suggested to use a more testable way for this stuff!

### Intro

Using static wrapper properties is a quick and easy way, but you can’t unit test them because they access HttpContext.Current directly. This time I will show you, how you can build a fully unit testable and strongly typed way to access your cookies. As there has been Christmas time 2 days ago (ASP.Net MVC RC1 was released *g*) I’m using the latest MVC bits for my example!

The cookie container is responsible for getting values out of and into the cookie collections. It does not know which concrete values I’m using in my application! This is implemented in a different level, so you can use this class for all of your applications!

In my implementation it’s possible to store “objects” in cookies. I’ve implemented it this way because I don’t want to convert all my DateTime, int, … cookies every time! But I also don’t want someone to save Lists or any other complex types, so my SetValue() method validates the type of the value and throws an exception, if it’s not a value type or nullable value type. That’s a little type checking, but I think it is worth it because cookies are set quite rarely!

## Use wrappers to access your cookies, sessions, ...

As described in my previous post, I will give you some more details about how you can access your cookies in a type-safe and easy way!

## Don't use Response.Cookies[string] to check if a cookie exists!

### The short explanation, if you don’t like to read the entire story

If you use code like if (Response.Cookies["mycookie"] != null) { … }, ASP.Net automatically generates a new cookie with the name “mycookie” in the background and overwrites your old cookie! Always use the Request.Cookies-Collection to read cookies!

## I'd like to announce ... myself!

I don’t know why, but due to some reasons, you stumbled upon this page! I’m happy to announce, that this page is going to be my attempt to make the world a better place for you – at least if you are a Microsoft .Net developer and if you – like me – love to learn new things!

### “WTF? Yet another blog about programming?”

If that’s what you are thinking right now, then my answer is “Maybe! But hopefully not!”. I will give my best to provide you with high quality information and if it saves you some hours then it served its purpose!

### What can you expect from this blog?

I’m a web developer and software architect. The things I like working with are constantly changing, as I really like to dive into new technologies! Currently I’m learning a lot about ASP.Net MVC and all the ALT.Net topics, so these will be the first topics I’m going to write about.