简体   繁体   English

配置多个ASP.NET MVC站点以使用单个数据库进行身份验证/成员身份

[英]Configuring Multiple ASP.NET MVC Sites To Use a Single Database For Authentication/Membership

Is it possible for two or more ASP.NET MVC sites to use a single SQL Server database for authentication and other things? 两个或多个ASP.NET MVC站点是否可以使用单个SQL Server数据库进行身份验证和其他操作?

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. 我目前有由asp.net_regsql.exe实用程序生成的身份验证表。 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... 我猜想这样做的方法是在那些表中以某种方式设置“ application_id”列...

Thanks in advance. 提前致谢。

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. 成员资格/角色/配置文件/会话提供程序通常可以选择包含“ ApplicationName”。此应用程序名称将用于过滤成员资格/角色/配置文件/会话查询。 You can set this applicationname in the web.config like this: 您可以像下面这样在web.config中设置此应用程序名称:

<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 在每个应用程序中更改此标记(默认情况下不是“ /”,但可以将其更改为所需的任何字符串),M / R / S / P提供程序将处理其余的标记

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM