Tuesday, November 2, 2010

Asp.Net Mystery Membership Database

Sherlock HolmesI’ve used the built-in Asp.Net Membership Provider a number of times for its simplicity and straight forward API. There are a few mystical elements that can trip you up, if you don’t understand how the provisioning process works. There are two primary options:

  • manual
  • auto-magical

Manual

I generally create the membership database before I start working on the user interface (seems logical right?). I do that by running the membership provider wizard by opening a Command Prompt, navigating to the .Net 2.0 framework folder and running the aspnet_regsql.exe command (c:\windows\Microsoft.net\framework\v2.0.50727\aspnet_regsql.exe on a 32bit OS).

Command Prompt to run aspnet_regsql.exe

That launches the setup wizard where you can choose how you want the database configured in your SQL Server instance:

  • use an existing database such as the application database or
  • a stand-alone membership database if you want to have multiple applications use the same membership database

ASP.NET SQL Server Membership database setup wizard

The wizard then runs the necessary scripts against the selected database (creating the database if it doesn’t exist) and populates it with the tables, views, and stored procedures that the API uses to manage the membership details.

Auto-magical

In case you hadn’t guessed, this is method enshrouded by mystery (not really, but it can seem like it). If you don’t choose to manually create your membership database (via the wizard), then the default option as defined in the machine.config file is to use a SQL Express database which ends up getting created in the application’s App_Data folder in Visual Studio.

<connectionStrings>
        <add name="LocalSqlServer" connectionString="data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|aspnetdb.mdf;User Instance=true" providerName="System.Data.SqlClient"/>
    </connectionStrings>

Depending on your version of Visual Studio and perhaps the method you use to initiate the creation of this database, it might not be obvious exactly where the database is or how it is configured to point to that database file. The corresponding connection string doesn’t necessarily show up in the web.config file because it is inherited from the one defined in the machine.config.

There are multiple ways you can initiate the creation of the membership database. A couple include:

  1. Select “ASP.NET Configuration” from the Visual Studio “Project” menu (screenshot is from VS 2010).image
  2. Drag a login control onto the design surface and select “Administer Website” from its context menu.Administer Website method of creating ASPNETDB.MDF

Upon first use of adding a user, role, or other activity a SQL Express database (ASPNETDB.MDF) will be created including the membership provider’s tables, views, and stored procedures used to manage the membership and personalization system.

Mystery

In a quick prototype project, I used the auto-magical process and added a few users. You will notice in the App_Data folder, there doesn’t appear to be an ASPNETDB.MDF, only a TeamStrength.mdf file, so where are my users stored?

ASPNETDB.MDF is not visible in Visual Studio Solution Explorer

Upon closer inspection with Windows Explorer, there actually is a membership database in that folder. ASPNETDB.MDF is visible from Windows Explorer

Mystery solved.

You may also be interested in my introduction to implementing ASP.NET Role Based Security presentation or the code samples from the presentation can be found through a link on that blog post.

Photo credit: m_bahareth / CC BY 2.0

Thursday, October 7, 2010

User Interface Design Patterns

custom flash video player controlsUser interface is as important as good coding practices. Here is a link to 40 Helpful Resources in UI Design Patterns.

Smileycat design elements showcase provides good food for thought for a variety of common page elements.

Tuesday, October 5, 2010

Managing Hyper-V Server without the MMC

V-Power Why might someone need or want to manage Hyper-V without the Machine Management Console snap-in? Maybe you want to use XP, Server 2003, or a Vista/ Windows 7 Home Premium or lower edition which is not supported by the Hyper-V MMC. This post is most relevant to a Hyper-V™ Server 2008 R2 installation, not Server 2008 R2 with the Hyper-V role.

Four options* for managing the Hyper-V environment:

* I will leave it as a homework assignment for you to determine which option may work best for you – if any.
photo credit: homard.net / CC BY 2.0

Hyper-V Poster

Slightly off topic, but Microsoft released a complex yet easy to read and informative Server 2008 R2 Hyper-V component architecture poster. A small snapshot of the poster is represented in the image below.
Hyper-v-poster-clip

Wednesday, September 29, 2010

Blocked and Encrypted Javascript Files and IIS Windows Authentication

lockout tagout I ran into an interesting issue with an application using a couple of javascript files I downloaded from the internet to modify and use in a web application for drop-down navigation. As long as I was accessing them using http://localhost, the javascript cascading menu functionality worked fine.

Windows Authentication

As soon as I started testing using http://machinename instead of localhost, I was prompted for my PC’s username and password. No problem, I realized I hadn’t disabled Windows Authentication in IIS 7 (since I was using Anonymous Authentication). When I disabled Windows Auth, the javascript didn’t work any more – even from running on the same physical PC. I turned Windows Auth back on and the javascript worked again.

Blocked

I figured there was probably some kind of trust issue, so I looked at the javascript filenames in Windows Explorer and found the names were colored green. I right clicked the properties and realized they were flagged as “Blocked” because they were downloaded in a zip file from the internet. I’ve run across that before so I clicked the “Unblock” button.

Encrypted

The files were still colored green and the javascript still didn’t work. I found that if I right clicked the filename, clicked on properties and “advanced”, the files were also encrypted. I unchecked the “Encrypt contents to secure data” checkbox and the javascript started working.

Problem solved.

photo credit: OhlieVher A. Arango / CC BY-ND 2.0

Monday, September 27, 2010

Project Phoenix Helps Non-Profits and Underemployed Developers

Phoenix rises from the ashes Unemployed or underemployed software developers have an opportunity to receive/earn a Visual Studio Ultimate license with MSDN among other great tools and learning opportunities. To qualify, the developer proposes a software project for a 503c non-profit, school, or church. See Arnie Rowland’s Like a Phoenix rising from the ashes post for full details about the program. The community benefits by receiving a service (software development) that might not otherwise be available to them.

Programs like these can only happen through the generosity of the MVP’s, and the numerous sponsors that have teamed up donating their time, talents, and/or products and services to the project.

photo credit: Gabi Agu CC BY 2.0

Thursday, September 16, 2010

Top Four Uses for Remote Desktop

  1. r/c helicopter Manage multiple PC’s or servers from a remote computer or location.
  2. Keep your data on a desktop in a secured premises and access it remotely. If your laptop gets lost or stolen, the data is still safely tucked away on your desktop at the home base.
  3. Fix a friend or relative’s PC without them lugging their equipment to your house or requiring a house call.
  4. Access your laptop from another computer when the laptop display or desktop monitor stops working.

photo credit: Locutis CC BY-SA 2.0

Wednesday, September 15, 2010

Why I Almost Switched from Hyper-V to VMware vSphere

I gave Hyper-V the good ol’ college try. I had a Windows 7 instance and a Windows Server 2008R2 Web edition instance installed. A few of the limitations that I didn’t like about Hyper-V:

  • Management Console only supported on Windows 7 Ultimate or Vista Ultimate (not Home Premium or XP – pretty limiting for a home virtual environment)
  • I couldn’t allocate any more RAM in total than was physically present on the Hypervisor – even if the instances were off. That doesn’t make it very easy to spin up a development or testing instance for quick testing and spin down
  • The hypervisor management console locked up causing me to hard boot both server instances and the hypervisor to get it running again
  • If I remoted or logged directly into the hypervisor (Server 2008R2 core install) itself and accidentally closed the command line window and cscript window, I couldn’t find a way to open them again without shutting down the server instances and power cycling the hypervisor. Yikes! that isn’t a very good production option.

The “Almost” in the title is because VMware vSphere and also Citrix XenServer both had compatibility problems with my hardware. Hyper-V worked right out of the box.