Using the Microsoft Access Providers for Membership, Roles and Profile under ASP.NET 4

Posted by: Imar Spaanjaars at Sunday, January 09, 2011 10:09:56 AM in: ASP.NET 4

Back in August 2006 I wrote an article about replacing the built-in Application Services providers (such as the Membership and Roles providers) with a new provider targeting a Microsoft Access database, instead of a SQL Server database. This solution has worked well for many people who didn't have access to SQL Server on their production machine, or couldn't (or didn't want to) spend a lot of money for an extended hosting package that includes SQL Server.

I wrote the article using Visual Studio 2005 and the Microsoft .NET Framework 2.0 which was the bomb at that time. And while you can continue to use the concepts explained in the article in web sites that target ASP.NET 4 today without any modifications (you can easily consume .NET 2.0 DLLs in an ASP.NET 4 web site), you may run into some issues when you also want to compile the Access Providers assembly against .NET 4.

In this article I'll show you how to make the Access Providers work under an ASP.NET 4.0 web site.

Read on ...

Building a Provider Based File Storage System Using .NET

Posted by: Imar Spaanjaars at Tuesday, August 10, 2010 7:03:55 PM in: ASP.NET 4

Many moons ago, in January 2007 to be exact, I wrote an article about storing files in the database using ASP.NET 2.0 and SQL Server. One of the features of the application I demonstrated in the article was the ability to switch between storing the actual file in the database, or saving it on disk. In both cases, meta data such as the content type and the original name were saved in the database, but by changing a configuration setting called DataStoreType you could determine if the actual file was saved on disk, or stored in an NText column in the database together with the meta data. In February of the same year, Steven Bey suggested to rewrite the application and base it on the provider model that has become a quite popular design pattern since it was introduced for the ASP.NET Application Services that appeared in ASP.NET 2.0. I added Steven's suggestion to my "Things to do when I have the time for them" list. And today is the day I finally found the time to do it. In this article I'll show you how I changed the application using the provider based model so you can switch between different providers, including various flavors of SQL Server and Microsoft Access. Adding support for other data stores then becomes really simple.

Read on ...

Programmatically Managing Application Services in ASP.NET

Posted by: Imar Spaanjaars at Wednesday, August 04, 2010 10:12:37 AM in: ASP.NET General

Since version 2.0, ASP.NET ships with a set of the so called Application Services, including Membership, the Role Manager, Personalization, Profile and the SqlWebEventProvider. To enable these features, you have a few options. The most common way is to just start using one of the features, such as Login control on an ASPX page. The default setup is configured to automatically create a SQL Server database in the App_Data folder of a site with the services already enabled. Another very common way, to get more control over the setup is to use the aspnet_regsql tool. This GUI or command line tool gives you more control over the SQL Server and database you're targeting and the exact features you want to install. The downside of this tool is that you need to run it locally and need the permissions to execute it.

I recently discovered that you can also manage the application services programmatically.

Read on ...

Making Application Configuration Easier Using the Castle DictionaryAdapter

Posted by: Imar Spaanjaars at Friday, July 30, 2010 12:17:07 PM in: ASP.NET 4
If you've done any development in ASP.NET, you're probably aware of the presence of the <appSettings /> element in web.config that enables you to store centralized configuration settings. You can use that element to store settings such as e-mail addresses and sender names for outgoing e-mail, settings that determine whether or not to send e-mail in certain conditions, default page sizes and a lot more. While this feature greatly decreases the troubles typically associated with configuration settings in multiple deployment scenarios (development versus a production environment for example), you can use an external component called the Castle DictionaryAdapter to make using the appSettings element even easier.
Read on ...

Welcome to the WebMatrix - Introducing Microsoft's new Web Stack

Posted by: Imar Spaanjaars at Tuesday, June 29, 2010 10:55:03 AM in: WebMatrix

Ever since Microsoft released ASP.NET in 2002, web developers have been able to use a powerful platform to build a wide range of web applications and services. But this power comes at a price. Getting started with ASP.NET takes quite some time and effort. Before you can run your first Hello World page, you need to download and install a lot of software, taking up quite a bit of time and bandwidth. You need Visual Web Developer (Express), you need SQL Server (Express or any other version) and you may need IIS if you want to test out more realistic scenarios, some of which require special privileges for the account you use on your machine. Once you have all the tools, the real work begins. My latest book, Beginning ASP.NET 4 in C# and VB needed 803 pages to take you from a developer newbie to a competent ASP.NET web developer.

In other words, you're facing quite some hurdles when you want to start developing web applications on the Microsoft platform, especially if you're a hobbyist web developer.

To make the Microsoft stack more appealing to beginning web developers, Microsoft is introducing WebMatrix.

Read on ...

Using Grouping instead of Distinct in Entity Framework to Optimize Performance

Posted by: Imar Spaanjaars at Monday, June 28, 2010 11:10:18 AM in: ASP.NET 4
On a number of pages on this web site I display a list of articles. For example, the home page shows a list of all articles from all categories. The FAQs page shows articles from the FAQs category only. Internally, the content items in the database (sorted in the Content table) are linked through a junction table to the Roles table. This enables me to publish content targeting specific roles. Anonymous users see content for the Anonymous role only, while, for example, I as the site administrator can see content that is assigned to the Administrators role only. I use this in order to add content to my site which is not public yet.
Read on ...

Using .Less to Change the Way You Write Your CSS

Posted by: Imar Spaanjaars at Thursday, June 03, 2010 9:10:24 AM in: ASP.NET General
I wanted to write a post about .Less for some time, but never found the right time to do so. Now that I am changing my own web site from ASP.NET Web Forms to ASP.NET MVC 2, I thought it was a good idea to incorporate .Less (pronounced as Dot Less) in my own web site and write a little blog post about it
Read on ...

Rebuilding imar.spaanjaars.com in ASP.NET MVC 2 - Part 5 - RTW

Posted by: Imar Spaanjaars at Tuesday, May 25, 2010 1:52:37 PM in: ASP.NET MVC
You may have noticed that I released the final MVC 2 version of my web site at imar.spaanjaars.com a few days ago.
Read on ...

Rebuilding imar.spaanjaars.com in ASP.NET MVC 2 - Part 4 - Repositories, Testability and Inversion of Control

Posted by: Imar Spaanjaars at Sunday, March 28, 2010 3:58:41 PM in: ASP.NET MVC

UPDATE: Links to the MVC site on the URL mvc.spaanjaars.com are no longer active, now that the site is live at imar.spaanjaars.com.

I just uploaded a new version of my web site in MVC to mvc.spaanjaars.com. This new version has the following features:

  • All data access is now done with repositories (using Entity Framework at run-time).
  • My Controllers and repositories are fully testable.
  • I am using Castle Windsor as my Dependency Injection tool to inject concrete repositories into my controllers at run-time or during testing.
Read on ...

Avoiding the "Works on My Machine" Syndrome

Posted by: Imar Spaanjaars at Saturday, March 20, 2010 2:40:42 PM in: Web General
A long time ago I worked on a web application for a large Dutch newspaper that provided access to all pictures that had ever been published in the paper, or were taken by photographers employed by the publishing agency. In total, there were around 250,000 pictures in the database used by the web application. One of the areas I worked on was the "picture list" that had features such as displaying, searching, filtering and paging of pictures. Things seemed to work fine on my machine, even with the large amount of pictures in the database. Until one day I worked from home.
Read on ... 1234567891011