Up until now I've been using an MVC Area for the administration part of my mvc applications, but recently I've been rethinking this due to the fact that you can't have more than one configuration for forms authentication per application.
This has become a problem becuase in a recent project I wanted to set the auth cookies not to expire for users, but I don't wan't this for administration users. I also don't want the user login page to be used to access the admin tools.
I'm considering setting up a seperate MVC project in the solution purely for admin tools. This seems to me the best option, but I'm wondering about complications with deployment. (Currently I'm using a Web Deployment Project in VS2008 to manage the build).
Does anyone currently use a seperate MVC project for the admin section? Any gotchas? Other opinions as to why this is not a good idea?
Thanks.
I'm always using a separate website for administration. But's it's primarily because the administration for my sites is totally different from the usage and therefore requires a different layout.
Another positive thing is that you don't have to wonder if users might be able to modify stuff that they shouldn't be able to modify since those parts are not built into the user web site.
Update
I mean Layout with Razor or Masterpage with webforms view engine.
We use http://admin.domainname.com and http://www.domainname.com to separate the sites. Quite easy to setup.
Seperating the sites also makes the controllers and views a lot cleaner since they only handle tasks for either administrators or users. No need for a lot of ifs (which otherwise can be very easy to add if you are like me = a lazy coder :)
The forms auth cookie could be path restricted for the admin-area, but that would give you some headache when dealing with the authentication, but might be possible to achieve.
Another option instead of using admin.hostname.com or anything like that, is to use a subapplication on /admin, however that wouldn't necessarily solve your problem.
We developed our web application as two different sites, mainly because we wanted the option to split the administration from the actual site, and also for scalability reasons. We wanted to be able to scale up the actual website in question, and not the administration part.
We have run into the following issues:
I think that for scalability reasons, you should consider separating the concerns, however it all lies on the design of your application if this is possible or not. We are building a framework for a certain type of websites, meaning that the actual implementation of the design differs from each and every customer, but we wanted a standardized way to administrate the site, so it was the logical choice for us.
The FormsAuthentication.SetAuthCookie
method allows you to control if it persists across sessions or not.
If they're an admin, set this to false
, otherwise to true
.
See http://msdn.microsoft.com/en-us/library/twk5762b.aspx for more info (the second parameter createPersistentCookie
controls this).
In terms of a different login page for different classes of user, you can return false from the authentication method if they're the wrong class of user and accessing the wrong login page.
All of this logic should happen before you set the authentication token.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With