DevelopmentNow Blog
 Tuesday, February 17, 2009

After spending a ton of time in Ruby on Rails we're getting back into some more PHP projects. And ASP.NET. :) Granted, it would be nice to only stick with one language, but a lot of our projects tend to involve solutions and packages instead of a lot of ground-up coding.

Anyhow, this is mainly a link for me to check out later if we need it: Tyler Hall's Simple PHP Framework.

http://code.google.com/p/simple-php-framework/wiki/ExampleWebsites

http://groups.google.com/group/simple-php-framework

 

 

February 17, 2009    Bookmark to Digg or other social bookmarking
#    Disclaimer  |  Comments [0]



 Thursday, March 27, 2008

Yeah so this isn't brand new. But the jQuery Cheat Sheet is for version 1.2, at least. Visual jQuery (which I still use a lot) is only for jQuery 1.1. I sure hope someone doesn't come out with a Visual jQuery clone for jQuery 1.2.X ... :)

March 27, 2008    Bookmark to Digg or other social bookmarking
#    Disclaimer  |  Comments [0]



 Wednesday, July 18, 2007

SubSonic is an open source project loosely modeled after Rails. It uses BuildProviders to automatically generate the DAL/ORM code at compile time, meaning you don't have to manually regenerate code every time your database schema changes.

The downside was that the code was only auto-generated for Web Site projects, not Web Application or Class Library projects. So Rob Conery has a recent post about using Pre-build Steps to autogenerate the SubSonic code for all types of projects.

So, read the "What will it do for me?" on the SubSonic home page, and check out the first 5-10 minutes of a recent screencast. If you like what you see, maybe try it out in your projects.

If you aren't already using DALs and code generation to accelerate your development work, you really owe it to yourself to check it out. :)

July 18, 2007    Bookmark to Digg or other social bookmarking
#    Disclaimer  |  Comments [0]



 Friday, March 23, 2007

This was inspired by a form post over in startupping, where people were discussing doing projects in ASP.NET or PHP (specifically, LAMP: Linux, Apache, MySQL, and PHP).

I do both ASP.NET (.NET 2.0, C#, SQL Server) & PHP development (LAMP). PHP is pretty easy to pick up (especially if you've programmed in classic ASP), and there's a lot of information, libraries, etc. out for it. For an IDE you could use Zend Studio ($99-$300), PHP Designer ($50+), or free ones like SciTE or PSPad (both are good).

If you just want to try out some PHP development, I'd suggest getting a cheap hosting account from GoDaddy, Dreamhost, or somewhere else. Or even e-rice.net ($10/year). While you could install Linux locally & play around with shell access & administering Linux, Apache, MySQL, and PHP, you could end up spending a lot of time being a Linux sysadmin -- time that you could have instead spent strengthening your PHP & MySQL skills. One step up from a cheap hosting account would be to run LAMP as a virtual machine by downloading the free VM player and ready-to-go LAMP packages.

Once you get beyond coding some basic stuff, you may want to look into better PHP frameworks to help accelerate your development. I like Code Igniter, but here's a list of other frameworks you can read about.

FWIW, I develop in both environments b/c I have a range of clients & projects w/ different needs. One of my current projects is a site that includes a lot of features (social networking, wiki, CMS, data management), but the client wanted to leverage existing open source libraries & avoid building everything from scratch. So LAMP was a natural way to go. Other clients are Microsoft shops, so they want .NET apps built that their existing IT staff can take over.

Like any project, I think deciding on a technology involves many factors -- how skilled are you in it? Do you want to learn a new technology? What does the technology cost? Are there things about this technology (language features, environmental features, pre-existing libraries & applications) that will help the project to be more successful?

Lastly, if it's costs that you're concerned about, IMO Microsoft projects aren't as expensive as some may think. You don't need to spend a lot of money on the IDE -- there are cheap or free IDEs you can develop in, or (if you qualify) you can enroll in the MS Empower for ISVs program for $375, which gets you an MSDN Universal license w/ OSes & dev tools. The .NET framework is free, and you can run IIS on XP Pro. SQL Server Express is free & has (almost) all the features that you'd be using in SQL Server Workgroup/Standard/Enterprise. I have a client that didn't have a very large database, so their production site runs on SQL Express.

Also, if you're using a hosting provider for your site (which you usually should), choosing a Windows OS & SQL Server for your hosting account isn't usually significantly more expensive than Linux.

Still, obviously LAMP is cheaper (free, unless you pay $$ for a better IDE), and Microsoft costs can add up if you're looking at big server farms or are buying your OS & SQL Server licenses outright (for some reason). But of course switching frameworks has its own cost in terms of time & mistakes made while learning. If I were building something simple from the ground up, I might just choose the platform I was strongest in.

March 23, 2007    Bookmark to Digg or other social bookmarking
#    Disclaimer  |  Comments [0]



 Tuesday, January 30, 2007

I was looking at wikis recently and thought I'd list out the ASP.NET wiki's I've noticed. Obviously there could be more, but here are the one's I've seen:

  • FlexWiki -- been around for a while, easy to install & use.
  • ScrewTurn -- has gotten some good buzz recently, seems the most active recently w/ a number of interesting features.
  • Perspective -- I recently noticed this. Has a WYSIWYG editor (which I think is good for corporate adoption). You can also attach & embed files (e.g. Microsoft Office Docs) & images, & search across them. Seems like it might be complicated to set up & install.

I believe they all can do authentication/authorization through NTFS and/or LDAP, so you can administer the permissions like you would any other IIS web site.

Here is a WikiMatrix comparison page of the above three wikis, although I don't believe their information is completely current.

January 30, 2007    Bookmark to Digg or other social bookmarking
#    Disclaimer  |  Comments [0]



 Sunday, January 14, 2007

As I mentioned in Social Networking for Sale, I believe social networking software/sites (SNS) will become pretty commoditized in 2007. It's already pretty cheap & easy to get your own community site.

For example, there's Scuttle, open source social bookmarking software. If you need social networking software (a la MySpace), you can find it for free/open source with Alicia (aka PHPizabi) or AroundMe or osDate or Yogurt or Dolphin.

If you want a fancier MySpace clone you can spend $300 or so for phpFox or Handshakes or BuddyZone or webNetwork or Elgg Spaces or SocialEngine or a dozen others. 

There are also hosted, turnkey solutions like PeopleAggregator, Me.com, NingPringo, KickApps, and others, which offer plans ranging from free to paid.

There's also a social networking addon for vBulletin called Zoints Local -- plug it into your existing vBulletin site and bingo! instant "community."

And of course there are "community" addons for CMS+ platforms such as phpNuke, Joomla (Community Builder), Drupal, etc. allowing you to truly build your own SNS. One could also do it by hand using Rails or some other rapid dev platform.

No matter which option you choose, you have a number of customization options, not all of which require a programmer.

The point of all those links is to reinforce the fact that there's already a slew of cheap starting points for a social community site for would-be MySpace topplers. I figure there will eventually be a number of vertical social networks (VSNs) for gamers, hobbyists, flyfishermen, cheerleaders, etc. Maybe they'll be within MySpace, or maybe third party sites. Better yet would be if VSNs could integrate with people's existing social networks elsewhere on MySpace, Facebook, LinkedIn, etc, so that you don't have to abandon your friends, profile, and blog posts to tap into a more targeted community. People would be more likely to join a new social network if they didn't have to reupload all their photos, reanswer all their profile questions, etc.

PHPizabi Alicia

 

Boonex Dolphin
dolphin.png

OSDate
osdate.png

Zoints Local
Zoints Local

January 14, 2007    Bookmark to Digg or other social bookmarking
#    Disclaimer  |  Comments [2]



 Tuesday, October 24, 2006

Google just announced Google Custom Search Engine, which allows you to create your own custom search engine and stick it on your site with a few lines of code. I was able to add one to http://www.developmentnow.com is about 5 minutes (look at the bottom of the blog page, or in the groups section e.g. at the bottom of this thread about web services).

One downside is that it relies on Google's index, so if your site isn't well indexed by Google (which mine isn't) your results are limited. But, it would be a nice thing for budding webmasters who don't want to build or maintain their own search engine, especially if they made sure to populate Google's index with Google sitemaps. And of course they make it really easy to incorporate AdSense into the search results.

October 24, 2006    Bookmark to Digg or other social bookmarking
#    Disclaimer  |  Comments [0]



 Thursday, July 27, 2006

Scott Mitchell wrote recently about a plug & play ASP.NET error-logging framework that he and Atif Aziz wrote for an MSDN article a while back. 

The framework is called ELMAH (Error Logging Modules and Handlers) and it's free & open source. Apparently you just install the DLL & add a few lines to your web.config, and it'll start logging errors while allowing administrators to view errors online or even access an RSS feed of recent errors. I usually install a global error handler in my ASP.NET apps & use log4net to log & email the information, but I never put together a web-based error viewer. So if there's a stable framework that wraps all that up, I'm all for it.

You can download & read more about ELMAH here. Some screenshots (courtesy of MSDN):


Viewing the error log


RSS feed of recent errors

July 27, 2006    Bookmark to Digg or other social bookmarking
#    Disclaimer  |  Comments [0]



So I was downloading the latest version of Anthem.NET to use for a Visual Studio 2003 project. I downloaded the zip, extracted, made the virtual directory, but kept getting weird security errors like

"The project location is not fully trusted by the .NET runtime. This is usually because it is either a network share or mapped to a network share not on the local machine.  If the output path is under the project location, your code will not execute as fully trusted and you may receive unexpected security exceptions."

and Visual Studio saying I can't debug the application. When I tried going to the local site in IE (localhost/Anthem-Examples-2003) I'd get

"Server cannot access application directory 'C:\Documents and Settings\Ben\My Documents\Visual Studio Projects\anthem\Anthem-Examples-2003\'. The directory does not exist or is not accessible because of security settings."

It always worked flawlessly before. So, after some dorking and searching around, I finally got it working, here's how I did it...

  • After downloading the zip file, I right clicked it and clicked "Unblock" (some new XP SP2 security thing). Then I extracted it. That resolved the first "project location not trusted" issue.
  • I then went to Control Panel->Admin Tools->.NET 1.1. Security Wizards, and gave full trust to the Intranet Zone.
  • I then disabled simple file sharing (Control Panel->Folder Options->View tab->Uncheck simple file sharing). This allowed me to access the "Security" tab on folders.
  • I then went to the folder containing the files that I extracted from the zip file. I right-clicked the folder, went to the (newly available) Security tab, and gave the Users group (of which the ASPNET account is part) standard (read/view/execute) access to that directory.

And now it works. I think a recent Windows security update is probably to blame. But, now we're back in action.

July 27, 2006    Bookmark to Digg or other social bookmarking
#    Disclaimer  |  Comments [0]



I forgot to include links for some of the libraries I used in my talk at Code Camp:

Atlas -- http://atlas.asp.net

Anthem -- http://www.anthemdotnet.com

Prototype -- http://prototype.conio.net/

script.aculo.us -- http://script.aculo.us/

 

July 27, 2006    Bookmark to Digg or other social bookmarking
#    Disclaimer  |  Comments [0]



 Monday, June 26, 2006

So you have an ASP.NET application and want to do some custom logging other than by using Response.AppendToLog(). Or maybe you have a console app that you want to log what it's doing. Good! Let's get you set up using log4net (a very popular logging library) in a few minutes so you can start keeping track of things. Much of this is based on Haacked's Quick and Dirty Guide to log4net, which is based on VS2003 but still a good read. I also got some tips for Visual Studio 2005 from Akash's blog. Now let's get started.

Download log4net

Download and extract the latest stable release of log4net here.

Add a reference

In your Visual Studio project, add a reference (Project->Add Reference) to log4net.dll (in the bin\net\<dotnet version>\release directory where you extracted the log4net zip file).

Add a log4net config file

Even though you can add log4net configuration settings to your app's main .config file, we're going to give log4net it's own config file for two reasons: 1) cleanliness, and 2) you can log4net change the config settings on the fly without having to restart the app. :)

So, create a new .config file in the root directory of your application ad name it log4net.config. If you're building a client app, set the "Copy to Output Directory" property to "Copy Always". Remove everything in the log4net.config file, and paste the below XML into it.  It contains sample configurations to log many types of events (info, warning, error, fatal) to a rolling set of log files in a "log4net" subdirectory in your application's root directory. It will also send emails for any error or fatal events. You'll at least want to change the Smtp settings to a valid host & email account.

<?xml version="1.0"?>
<log4net>
    <appender name="SmtpAppender" type="log4net.Appender.SmtpAppender">
        <to value="support@yourcompany.com" />
        <from value="support@yourcompany.com" />
        <subject value="ERROR on site" />
        <smtpHost value="your.smtp.host" />
        <bufferSize value="256" />
        <lossy value="true" />
        <evaluator type="log4net.spi.LevelEvaluator">
            <threshold value="ERROR" />
        </evaluator>
        <layout type="log4net.Layout.PatternLayout">
            <conversionPattern value="%-5p %d [ThreadId: %t] Class:%c{1} Method:%M %nMESSAGE:%n%m%n%n" />
        </layout>
    </appender>
    <appender name="RollingLogFileAppender" type="log4net.Appender.RollingFileAppender">
        <file value="log4net\\logfile.txt" />
        <appendToFile value="true" />
        <datePattern value="yyyyMMdd" />
        <rollingStyle value="Date" />
        <filter type="log4net.Filter.LevelRangeFilter">
            <acceptOnMatch value="true" />
            <levelMin value="INFO" />
            <levelMax value="FATAL" />
        </filter>
        <layout type="log4net.Layout.PatternLayout">
            <conversionPattern value="%-5p %d %5rms %-22.22c{1} %-18.18M - %m%n" />
        </layout>
    </appender>
    <root>
        <level value="DEBUG" />
        <appender-ref ref="SmtpAppender" />
        <appender-ref ref="RollingLogFileAppender" />
    </root>
</log4net>

Initialize the configuration

If you're using a web application, add the following line to your Application_Start method in global.asax.

log4net.Config.XmlConfigurator.ConfigureAndWatch(new System.IO.FileInfo(Server.MapPath("log4net.config")));

If you're using a client application (e.g. a console app), add the following line to your app's initialization routine:

log4net.Config.XmlConfigurator.ConfigureAndWatch(new System.IO.FileInfo("log4net.config"));

These lines tell log4net to load configuration information from the local log4net.config file and watch it for any configuration changes while the app is running.

Start logging

Now wherever you want to log some information in a particular class, add a member variable like this

private log4net.ILog logger = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);

This creates a logger variable, and causes log messages to be prefixed with the class name containing the logger variable. That makes it easier to sift through logs, since you'll be able to see which messages came from which classes.

Then when you want to do some logging you can just use statements like this

logger.Info("some info");
logger.Warn("a stern warning!")
logger.Error("An error occurred!");

Reading the logs

The sample config (above) creates a log file named logfile.txt in a log4net subdirectory inside your application's root directory. Note that for client applications, that'll be your bin/debug or bin/release folders (or wherever the EXE lives). Since we used a RollingLogAppender, older logs will be archived with the date apprended to the file name. That means that "logfile.txt" only contains messages for the current day.

Deploying your app

When you deploy your application, make sure to deploy the log4net.dll, log4net.xml, and log4net.config files. Also make sure that your application's account (e.g. the ASPNET account for web apps, or the user for client apps) can create and write to the "log4net" subdirectory. For web applications you may want to go ahead and create the "log4net" subdirectory up front and assign ASPNET full control rights to that.

Tweaking the configuration

You can tweak the settings in your log4net.config at any time, even while the app is running. You may wish to change the location of the log file, or add different appenders, or change what type of messages get logged. I suggest reading the log4net documentation for more information.

 

 

 

June 26, 2006    Bookmark to Digg or other social bookmarking
#    Disclaimer  |  Comments [0]



 Friday, June 23, 2006

Google recently released an API for Google Calendar. Even though the Google Calendar UI is already pretty slick, developers can now write applications to extend the functionality further. C# and Java versions of the API are available.

For example, you can query your upcoming events in C# like so:

  1. First download & install the libraries. You may need to build them first.
  2. Make a new project and reference GData.dll, GDataExtensions.dll, and CalendarService.dll
  3. Use code kinda like the below :)


using System;
using System.IO;
using System.Xml;
using System.Net;
using Google.GData.Client;
using Google.GData.Extensions;
using Google.GData.Calendar;

namespace ConsoleApplication1
{
    class Class1
    {
        [STAThread]
        static void Main(string[] args)
        {
            string calendarURL = "http://www.google.com/calendar/feeds/default/private/full";
            string appName = "MyCompany-MyApp-v1.0";
            string userName = "you@someisp.com";    // google calendar login
            string password = "somepassword"; // google calendar password

            // create a query object
            // get 10 entries that start between now & the next 10 days
            EventQuery query = new EventQuery();
            query.Uri = new Uri(calendarURL);
            query.NumberToRetrieve = 10;
            query.StartTime = System.DateTime.Now;
            query.EndTime = System.DateTime.Today.AddDays(10);

            // connect to the calendar service
            CalendarService service = new CalendarService(appName);
            service.setUserCredentials(userName, password);

            // execute the query & get the results back
            EventFeed calFeed = service.Query(query);

            // iterate through the results
            foreach (EventEntry feedEntry in calFeed.Entries)
            {
                string eventStartDesc = "n/a";
                string eventWhereDesc = "n/a";
                
                if (feedEntry.Times.Count > 0)
                {
                    When eventStart = feedEntry.Times[0];
                    if (eventStart.AllDay)
                        eventStartDesc = "All day";
                    else if (eventStart.StartTime.Date == System.DateTime.Today.Date)
                        eventStartDesc = "Today at " + eventStart.StartTime.ToShortTimeString();
                    else
                        eventStartDesc = eventStart.StartTime.ToString();
                }

                if (feedEntry.Locations.Count > 0)
                {
                    Where where = feedEntry.Locations[0];
                    if (where.ValueString != null || where.Label != null)
                        eventWhereDesc = where.Rel + " " + where.Label + " " + where.ValueString;
                }

                Console.WriteLine("Event:");
                Console.WriteLine("\tTitle: " + feedEntry.Title.Text);
                Console.WriteLine("\tWhen: " + eventStartDesc);
                Console.WriteLine("\tWhere: " + eventWhereDesc);

            }
        }
    }
}


As you can see, it's pretty easy. Note that you should change the username & password information at the top, and make sure you have some upcoming events in your calendar.

You can also download a sample .NET 1.1 project here.

June 23, 2006    Bookmark to Digg or other social bookmarking
#    Disclaimer  |  Comments [0]



 Wednesday, May 17, 2006

Google just blogged about the Google Web Toolkit, a development framework that allows you to write an application in Java and convert it into a working AJAX app. I've always felt that using a toolkit or framework is good when they work -- why reinvent the wheel coding low-level stuff when you can use someone else's to implement your own high-level stuff faster and easier? Unless your product idea is to actually make something low level. As in if you're Google and making a toolkit, say for AJAX apps.

May 17, 2006    Bookmark to Digg or other social bookmarking
#    Disclaimer  |  Comments [0]



 Friday, May 12, 2006

As I posted previously, this was going to be a longer post. But it got erased because I clicked the wrong button on my mouse, so you all get the Cliffs Notes version. But that's ok, you're a clever group. All three of you. :)

ASP.NET 2.0 Membership

As you may know, ASP.NET 2.0 comes with ASP.NET 2.0 Application Services, a motley gang of controls and APIs that offer basic building blocks for whipping together sophistication web sites with almost no code at all. For example, let's say you wanted to create a web site that required users to register and log in before accessing certain portions, and be able to have different types of users who could access different areas, and even store personalized information about those users. In the past you'd have to code it all yourself, but not any more. There are a series of APIs that you can access and web controls that work against those APIs. For example,

  • Membership -- stores usernames, passwords, and handles credentials
  • Roles -- groups users in roles
  • Profiles -- lets you store specific information (e.g. favorite color) for users
  • Personalization -- works with Web Parts to customize web controls so users can have their own, personalized web pages (think My Yahoo)

One nice thing is the APIs are simply interfaces to the data -- they don't deal with storing it. Instead, data is persisted via various providers that communicate with the APIs. So you could choose to have the Membership API work with a Membership Provider called XMLMembershipProvider that knew how to store membership data in an XML file. You could then change your mind and switch to using a provider called MySQLMembershipProvider that stored data in a MySQL Database, and you wouldn't need to change any code. Think of the APIs as object oriented interfaces, and the providers as implementations of those interfaces.

So Many Providers, So Little Time

ASP.NET comes with a few built-in providers (SQL Server, SQL Server Express, XML), but there's nothing stopping you from writing your own provider if you want to store the data in a different or proprietary way. You can download Microsoft's Provider Toolkit and have a go. As a bonus, there's a sample Microsoft Access provider for those of you who want to/have to store your information in an Access database.

By default, ASP.NET 2.0 uses a set of providers that store data in a SQL Server Express database located in your web site's App_Data folder. Which is nice in that your site is self-contained and you don't need to have "normal" SQL Server. But it's bad in that SQL Server Express is kinda wimply, many hosting providers don't support it, and it complicates xcopy deployment because the last thing you want to do is copy your development usernames on top of the production set.

If you have SQL Server Standard/Express 2000/2005 available, you may as well use it as the provider. Here's how.

Configure Your SQL Server for Application Services

First you'll need to install some stored procedures and tables in whatever SQL Server database you plan on using. Thankfully, there's a tool that makes this easy. Navigate to C:\Windows\Microsoft.NET\Framework\2.0.<latest> and run aspnet_regsql.exe. Perform the following steps:

  • Click Next.
  • Check "Configure SQL Server for application services" and click Next.
  • Connect to your database server and choose your database from the dropdown. The database you choose will have some tables and procs added for membership et al. Click Next.
  • Click Next to confirm.
  • Wait a bit, and you're done. Click Finish.

If you can't or won't run aspnet_regsql.exe (e.g. your company policies require database changes to be in scripts), there are a number of "Install" .sql files that you or your DBA can run. InstallCommon.sql will need to be run first, and you'll need to change the @dbname variable at the top of each script.

Either way, once the database is configured, you can take a look at what got added -- you'll see a number of databases starting with aspnet_ that will contain the membership information.

Add a SQL Server Provider to Your web.config

Next you want to have ASP.NET use that SQL Server database instead of the Express database.

ASP.NET normally accesses the SQL Server Express database via a provider named "LocalSqlServer," and Scott Guthrie posted a tip on renaming that provider so that it instead points to whatever SQL Server database you want. I don't like doing that because a) it's tricking ASP.NET, and b) you run the risk of confusing people by having a provider named "LocalSqlServer" point to something that may not be local. But, it's easy to do if you want to -- just add the following lines to your web.config's <connectionStrings> section:

<remove name="LocalSqlServer" />
<add name="LocalSqlServer" connectionString="YOUR CONNECTION STRING" providerName="System.Data.SqlClient"/>

Anyhow, we're not going to do that. We're going to add explicit lines for our SQL Server database. First ensure there's a connection string in your web.config for your Sql Server.

    <connectionStrings>
        <add name="myConnectionString" connectionString="Data Source=myserver;Initial Catalog=mydatavase;Persist Security Info=True;User ID=myuser;Password=mypassword" providerName="System.Data.SqlClient"/>
    </connectionStrings>

Next, add a Membership section and provider to your web.config's <system.web> section:

<membership>
   <providers>
   <add

      name="MySqlServerMembershipAuthentication"

      connectionStringName="myConnectionString"

      applicationName="/MyApplication"
      description="This is a test database"

      requiresUniqueEmail="false"
      enablePasswordRetrieval="false"

      enablePasswordReset="true"

      requiresQuestionAndAnswer="false"
      passwordFormat="Hashed"

      minRequiredPasswordLength="4"

      minRequiredNonalphanumericCharacters="0"
      type="System.Web.Security.SqlMembershipProvider, System.Web, Version=2.0.3500.0, Culture=neutral,

         PublicKeyToken=b03f5f7f11d50a3a" />
   </providers>
</membership>

Use the right connectionStringName for your database, and give it a name you like. The applicationName attribute doesn't have to be your virtual directory, but it should be unique to your application. This allows different applications to have users with the same name in the same database without colliding. You can read more about the attributes on MSDN, but remember that if you choose Encrypted for passwordFormat, you should include your own validation and decryption keys in your web.config like I blogged about previously on passwordFormat.

Lastly, if you plan on having user roles (Admins, Members, Serfs, etc) add a roleManager section to the <system.web> section:

<roleManager enabled="true">
<providers>
<add name="MySqlServerRoleManagerProvider"
connectionStringName="myConnectionString" applicationName="/MyApplication"
type="System.Web.Security.SqlRoleProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
</providers>
</roleManager>

Tell ASP.NET to Use Your New Providers

Now let's configure ASP.NET to use the new providers you specified. In Visual Studio, click Website->ASP.NET Configuration from the menu. You'll see the ASP.NET Web Site Administration Tool, which allows you to create users and roles, define application settings, and choose providers. Click the Providers tab, then click "Select a different provider or each feature." You should see your new entries there.

Go ahead and select your new providers, and click Test to make sure they're working correctly. If you want to click the other tabs to see what features they offer, go ahead and do so.

Create a User

Let's create a user, just for testing. Click the Security tab. Click Create User, enter some test values (I named my user "test"), and click the Create User button. It'll say whether the user has been successfully created or not. 

Assuming the user was made successfully, close the window, and take a quick look at your web.config file again. You'll see that the attribute defaultProvider has been added to the roleManager and membership tags. You can actually set that value manually in the web.config instead of using the administration tool.

For fun, connect to your SQL Server database again and view the aspnet_Users table. You should see the new user you created. Notice how the user has a unique UserId and ApplicationId, allowing different applications to have their own separate set of users.

 

If you view the aspnet_Applications table you'll see the applicationName you chose in your membership section. The user's password and other information are stored in the aspnet_Membership table. You can poke around a bit more, then delete the user by opening up the Web Site Administration Tool, going to the Security tab, clicking Manage Users, selecting the user and clicking Delete User.

Roles and Controls

Now that you're set up for ASP.NET Membership, you can open up the Administration Tool again to create some Roles and more users and/or you can go ahead and drag Login, LoginView, ChangePassword, etc. controls onto your web forms. You'll find them under the Login section in the Visual Studio toolbox when editing ASPX pages. Most of the Login controls need no code at all -- you can edit their templates, and they'll automatically read the membership information from your web.config and the providers.

Directories in your site can then be protected by creating a web.config inside them and using simple authorization blocks, e.g. inserting

<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.web>
<authorization>
<allow roles="SomeRole" />
<deny users="*" />
</authorization>
</system.web>
</configuration>

protects a directory from everyone except users in the role "SomeRole."

Conclusion

Well, what started out as a Cliffs Notes got bigger than I expected, but that's OK. Hopefully I've shown you enough to not only free yourself from SQL Server Express, but encourage some of you to dive into the ASP.NET Membership system.

May 12, 2006    Bookmark to Digg or other social bookmarking
#    Disclaimer  |  Comments [0]



 Wednesday, February 15, 2006

Like many developers, I've been intrigued by the hype around Ruby on Rails, but of course I don't have a Linux box handy and don't feel like setting up Apache, etc to try it out. What's a lazy programmer to do?

Enter Instant Rails, especially designed for Windows developers. From the description:

Instant Rails is a one-stop Rails runtime solution containing Ruby, Rails, Apache, and MySQL, all preconfigured and ready to run. No installer, you simply drop it into the directory of your choice and run it. It does not modify your system environment.

You can download Instant Rails here.

 

February 15, 2006    Bookmark to Digg or other social bookmarking
#    Disclaimer  |  Comments [0]



 Sunday, February 05, 2006

I was using Kayak today and noticed they had a link about their technology. One thing I noticed was that they use Ruby, which I've been reading about more lately, especially the uber-sexy Ruby on Rails. But Kayak also mentioned that they use memcached to cache common database results. It's basically a super-fast distributed dictionary (key/value pairs) object that you can spread across multiple servers without replicating data all over the place.

Since I'm a Microsoft developer, I normally cache web server stuff using the good ol' Cache object, or maybe the Caching Enterprise Library. Which works fine. But memcached makes a good point, in that if you have, say, 50 web servers, running multiple processes, then you're going to be potentially storing the same data multiple times on every machine. memcached stores your data once, and scales across as many machines as you run it on. And since memcached is built as a caching system, it could potentially be much faster than caching things in a database.

But don't take my word for it, especially since I'm just paraphrasing their "about" page. Read more about how it works on the memcached home page ... if it sounds intriguing to you, you should check it out. What's the worst that could happen? :)

February 5, 2006    Bookmark to Digg or other social bookmarking
#    Disclaimer  |  Comments [0]