views:

32

answers:

1

I am creating an ASP.Net MVC website that I am launching soon in private beta.

What I am using.

  • ASP.NET MVC 2
  • ASP.NET Sql Membership Provider
  • Authorization Attributes on ActionMethods. ex. [EditorsOnly]

What I am trying to accomplish:

  • During the private Beta period of my website, I want no anonymous users to access my site.
  • Only Beta Testers of my site should be able to login and use my site as normal.
  • After the private beta period people can access it using the security structure I already have set up.
  • I am hoping I do not have to recompile but can have a setting in the webconfig to switch between Private Beta mode to Normal mode.

Thanks for your suggestions.

A: 

What if you had two sets of controllers that were identical except that the authorization attributes differed from one to another. Now I'm usually one to strongly shy away from code duplication, but this only duplicated for a finite period of time where you later remove the duplicated code. If you do this, then you can route your pages to the "beta" controllers during beta time and reroute to the "live" controllers when you make the switch. Doing it this way means you only make changes in the global.asax file to "flip the switch". You can then later remove the "beta" controllers on your own schedule.

There might be a better solution but I don't think this is that bad of an option. This is a bad long-term solution but your requirements, by definition, makes it a short-term solution.

Jaxidian
Hmm, did I over-complicate this when you could simply create your "beta" controllers by inheriting the "live" controller? This would reduce code duplication for the actual content of the code. Your "beta" controllers would be decorated slightly differently but would just keep calling `base.Foo()` for most of it. Same concept as my post, but with OO.
Jaxidian
Thanks Jaxidian, Yep that would work. I thought perhaps that there was something simple I could do by overriding something in the Controller Factory, or the membership provider. Or a universial method that I can put some code that redirects to login if they are not in the beta user role. But I may be over complicating the problem.
Mark Kitz