Google Apps, hosted software. Learn More.

Web News

Samsung appoints new country head for mobile division
Consumer electronic firm Samsung Electronics Friday announced the appointment of Sunil Dutt as its new country head for the company's mobile business unit. In his last capacity, Dutt was Nokia India's sales...

Gulf Finance Plans $10 Billion Business Park in India
Gulf Finance House EC, a Bahrain- based investment bank, is building a $10 billion energy and software city in India, taking overseas investments by Persian Gulf states this year to a record $85 billion. The Islamic...

India PC shipments grew 20 percent in third quarter
Mobile PC sales clocked nearly triple digit growth predominantly driven by retail sales in the home market. “HP continues to retain its number 1 position, constantly widening the gap with its closest competitor HCL, through a robust growth in mobile PC shipments. Lenovo...

Spice Local Lingo Service announced in Bangalore, India
Spice Telecom has unveiled the Spice Local Lingo service in Bangalore, India. The new service will allow Spice customers to SMS in twelve Indian regional languages. At present the Spice Local Lingo enables sending text...


Sign Up For adCenter - Get $50 In Free• Clicks.
12.14.07


Using The Provider Model In ASP.NET 2.0

By Mads Kristensen

I think by now, most ASP.NET developers have come across some of the different provider models in ASP.NET 2.0.

Most likely the Membership, Roles and SiteMap provider but also the custom provider model that you can use to create your own providers.

Still, I often come across custom authentication and authorization mechanisms instead of using the Membership and Roles provider model. Typically, a business object called User has a Logon method that does the authentication and returns a Boolean back to the login page, which sets a cookie and maybe session variable and then redirects the user to the password protected area of the website.

Then there's usual also some custom authorization mechanism that prevents certain logged in users from certain areas such as admin pages. The menu is custom designed to hide and show only the pages available to the current user and the individual pages also makes the checks.

That is a common scenario and I see it very often. If you have such a scenario on your web application, then consider converting your existing logic to use the provider model. By creating a custom implementation of the Membership, Roles and SiteMap provider, you get all this for free and it is very simple to do so. You can keep your existing code and then build the providers on top of that.

Google Apps, hosted software. Learn More.

The benefit is that these three providers work together so that the SiteMap automatically shows only the pages a user has permissions to see based on her role. You also get the cookie management for free. But the best part is that you can easily switch to a new provider when needed without changing your existing code. I did that today when I installed BlogEngine.NET on our intranet at ZYB. It had to use the Active Directory Membership provider so that we could log on using our network credentials. It took me 5 minutes to make the transition from my custom XML Membership provider to the Active Directory one. There's a good guide at MSDN for using the Active Directory provider.

That flexibility comes free of charge with ASP.NET 2.0 and makes the lives of all .NET web developers much easier, more flexible and powerful. I have published my XML Membership provider and will wrap up the XML Roles provider soon and publish it as well.

When you first try the provider model, I promise that you'll never go back.

Resources

Video: Create a Custom Membership Provider
Sample Role provider implementation
Membership and Role providers in ASP.NET 2.0
Examining ASP.NET 2.0's Site Navigation
SiteMap provider introduction

Comments

About the Author:
Mads Kristensen currently works as a Senior Developer at Traceworks located in Copenhagen, Denmark. Mads graduated from Copenhagen Technical Academy with a multimedia degree in 2003, but has been a professional developer since 2000. His main focus is on ASP.NET but is responsible for Winforms, Windows- and web services in his daily work as well. A true .NET developer with great passion for the simple solution.

http://www.madskristensen.dk/

About DevWebPro India
DevWebPro India is for professional developers ... those who build and manage applications and sophisticated websites. DevWebPro India delivers via news and expert advice New Strategies In Development.

DevWebPro India is brought to you by:

SecurityConfig.com NetworkingFiles.com
NetworkNewz.com WebProASP.com
DatabaseProNews.com SQLProNews.com
ITcertificationNews.com SysAdminNews.com
LinuxProNews.com WirelessProNews.com
CProgrammingTrends.com NetworkNewz.com


-- DevWebPro India is an iEntry, Inc. publication --
iEntry, Inc. 2549 Richmond Rd. Lexington KY, 40509
2007 iEntry, Inc.  All Rights Reserved  Privacy Policy  Legal

archives | advertising info | news headlines | free newsletters | comments/feedback | submit article


New Strategies In Development DevWebPro India News Archives About Us Feedback DevWebPro India Home Page About Article Archive News Downloads WebProWorld Forums Jayde iEntry Advertise Contact