Friday, October 03, 2008

ASP.NET 2.0 Membership provider

ASP.NET 2.0 membership provider have been for more than 2 years and initially, I thought it’s just a show off feature of ASP.NET 2.0 and that would not be practically useful before I explored it into detail.

From time to time, every asp.net web application requires membership, authentication, authorization, etc, it’s a waste of time that we don’t have reusable model for those even though every web application requires those functions. So, I started exploring what’s available in built in ASP.NET Microsoft model and how others people do in terms of reusable model or provider for this.

Then, I found out that ASP.NET membership is really good design even though it may not be 100% perfect. It's really customizable, robust, extendable, easily pluggable and also easier to integrate into the project without much efforts. I’m not sure whether it’s good enough for enterprise level website for millions of users but it’s pretty good enough for SME or normal web application.

This really saves 20% to 30 % of small and medium side web application development and the code is modular and reusable. I really loves it.

This can be easily integrated with Menu SiteMap navigation based on dynamic user roles, User Roles provider, Personalization and the provider can be plugged & play with custom own provider by just configuring in web.config.

Currently, I'm just using built in SqlMembershipProvider and I handle my own Users information table for extended fields of users. The drawback with this is I need to duplicate user record in my own user table whenever new record in membership table is created.

You can also create your own custom membership provider by deriving from MembershipProvider class and override methods.

Microsoft also provides the source code and it can be learned how their code is. By learning this, you can probably design better than what it has and which suits to your requirement as well.

The following links would be useful for getting started.

http://weblogs.asp.net/scottgu/archive/2006/02/24/ASP.NET-2.0-Membership_2C00_-Roles_2C00_-Forms-Authentication_2C00_-and-Security-Resources-.aspx

Providers Source code download

http://weblogs.asp.net/scottgu/archive/2006/04/13/442772.aspx

http://download.microsoft.com/download/a/b/3/ab3c284b-dc9a-473d-b7e3-33bacfcc8e98/ProviderToolkitSamples.msi

ASP.NET Provider Detail Explanation

http://msdn.microsoft.com/en-us/library/aa478948.aspx

ASP.NET Provider book

http://download.microsoft.com/download/d/d/b/ddb5a94d-b398-44b5-bbb9-a71808879d79/Microsoft%20ASP.NET%20Providers.pdf

Thursday, July 03, 2008

MasterPage.master.cs does not exist error

I got the very weird error with ASP.NET 2.0 deployment. It has been running well in my development machine. Then, I published my test WebApplication project from visual studio to make release the compiled dll so that the application can be run on server without deploying .cs source code files. But after published it, the system gave the error “MasterPage.master.cs does not exist”.

It was very weird and it tempted to me considering whether it’s because “.cs” files are also required to deploy. But if that’s was the case, what’s the point of publishing?

After a while, then I finally realised that MasterPage I created doesn’t have namespace.

After I added namespace in masterpage.master.cs file and published it again. Then, It was fine.

In ASP.NET 2.0, it seems like

- WebApplication project requires to have namespace for every class in the project if you deploy the system by publishing (.dll and aspx only).

- WebSite project, it seems doesn’t require to have namespace even though if you deploy it by publishing.

Server Error in '/WebAppTest' Application.


Parser Error

Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately.

Parser Error Message: The file '/WebAppTest/MasterPage.master.cs' does not exist.

Source Error:

Line 1: <%@ Master Language="C#" AutoEventWireup="true" CodeFile="MasterPage.master.cs" Inherits="MasterPage" %>

Line 2:


Source File: /LEGATOTest3/WebAppTest.master Line: 1


Version Information: Microsoft .NET Framework Version:2.0.50727.1434; ASP.NET Version:2.0.50727.1434

Wednesday, June 11, 2008

ASP.NET Menu & DataSet

I had a requirement to build dynamic configurable menu and data will be populated from database rather than web.sitemap. And also the menu must support unlimited hierarchical levels. And also this piece of code must be reusable.

My idea was to bind the menu directly with dataset but unfortunately, dataset is not inherited and implemented IHierarchicalDataSource and it throws the exception. So, I tend to do traditional way of by adding menuItem in the loop. I know this is not a good idea and there must be someone who already implmented the neater way of binding directly by tweaking the dataset as the ASP.NET Menu has been released since 2 or 3 years ago.

Just a couple minutes spending on google and found this which is neater code and better design.

http://aspalliance.com/822

By using XMLDataSource and XSLT, this support unlimited hierarchical levels and only a few line of codes and clean.

Just have a look that above link if you are looking for building dynamic menu, it's worth to look it at.

Cheers

kick it on DotNet