Recent
Articles |
Using The Provider Model In ASP.NET 2.0 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...
Googlebots Can Trip Bugs In ASP 2.0? In a post called, "ASP.NET 2.0 Mozilla Browser Detection Hole," Brendan Kowitz writes that 'there is something drastically wrong with the way search engines have been indexing my ASP.NET 2.0 blog.' Back in March 2006...
Show IIS Process Info Recently I needed to investigate the IIS process on a website because of strange shutdown behaviors. There are many ways to dig into the IIS process but on a hosted environment it can be a little hard since...
ASP.NET 2.0 - The Expando Attribute By coincidence I noticed a method I've never seen before on the ClientScript property of the page class in ASP.NET 2.0. It's called something as cryptic as Register Expando Attribute and it's very useful. It can set JavaScript...
URL Rewrites & The HtmlForm Action Attribute A known bug in ASP.NET 1.x and 2.0 is that the action attribute of a form doesn't respect URL rewrites. Everyone that uses URL rewrites uses one of several mechanisms to take care of the action attribute bug. Recently it has...
Startups Aren't Thinking About ASP.Net Higher costs and fewer skilled .Net hackers may be limiting startups to going with the hordes of Linux and C/C++ or Java developers and tools available when setting up shop. Long ago I asked the ColdFusion...
|
|
01.18.08
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.
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/
|