views:

78

answers:

1

Is it possible for two or more ASP.NET MVC sites to use a single SQL Server database for authentication and other things?

Here's how I'm thinking of setting it up: I will combine the current database of each site into one single database, prefixing the tables with the name of the site they belong to. I currently have authentication tables generated by the asp.net_regsql.exe utility. How should I combine those tables? I'm guessing that the way to do it is to somehow set the "application_id" column in those tables...

Thanks in advance.

+1  A: 

The membership/role/profile/session providers usually have an option to include an "ApplicationName" This applicationname will be used to filter out the membership/role/profile/session queries. You can set this applicationname in the web.config like this:

<providers>
  <clear/>
  <add name="ProviderName"
     (...)
     applicationName="/"
     (...)
     >
</providers>

Change this tag (by deafult is't "/", but you can change it to any string you want) in each application and the M/R/S/P provider will take care of the rest

SztupY
So this means that my hypothetical design of combining the databases will work? Thanks!
Maxim Zaslavsky