ASP.Net MVC 3 配置

发布于 2024-12-05 20:30:13 字数 327 浏览 0 评论 0原文

我想问一下 ASP.Net 配置。我有一个使用 ASP.Net MVC3 的项目。我在我的项目中使用会员资格。在我的数据库服务器中,我的项目有 2 个数据库。

  1. aspnetdb,包含aspnet_membership、aspnet_user、aspnet_roles等(我使用asp.net配置)
  2. mydatabase,它用于我的项目数据库。

现在,我的老板告诉我,他想公开托管我的项目,并告诉我只使用一个数据库。所以我必须将 aspnetdb 移动到 mydatabase。我怎样才能做到这一点而不在 mydatabase 中创建新表?

谢谢

i want to ask about ASP.Net Configuration. i have a project that use ASP.Net MVC3. and i use membership in my project. in my database server, there's 2 database for my project.

  1. aspnetdb, contains aspnet_membership, aspnet_user, aspnet_roles, etc (i use asp.net Configuration)
  2. mydatabase, its for my project database.

now my boss told me that he want to host my project in public and told me to use only one database. so i have to move aspnetdb to mydatabase. how can i do it without making new table in mydatabase ?

thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

无声情话 2024-12-12 20:30:13

默认情况下,ASP.NET 会员资格提供程序使用名为 LocalSqlServer 的内置连接字符串,如下所示:

<add name="LocalSqlServer" 
     connectionString="Data Source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|aspnetdb.mdf;User Instance=true" 
     providerName="System.Data.SqlClient"/>

当您第一次使用 Membership 时(或者当您使用Web 配置管理器工具),将自动创建 aspnetdb.mdf。第一步,您可以通过 clear 命令从 web.config 中删除此 connectionString

  <connectionStrings>
    <clear/>
    <!-- your other connectionStrings -->
  </connectionStrings>

此外,您还必须更改 connectionString< /code> 用于 web.config 文件中的 membershipProvider(还有 roleProvider 如果您使用它):

<membership userIsOnlineTimeWindow="20">
  <providers>
    <clear />
    <add
         connectionStringName="YourSpecifiedConnectionString" // your connectionString here
         name="AspNetSqlMembershipProvider" 
         type="System.Web.Security.SqlMembershipProvider" 
         enablePasswordRetrieval="false" 
         enablePasswordReset="true" 
         requiresQuestionAndAnswer="false" 
         requiresUniqueEmail="false" 
         maxInvalidPasswordAttempts="500" 
         minRequiredPasswordLength="1"
         minRequiredNonalphanumericCharacters="0"
         passwordAttemptWindow="10"
         applicationName="/" />
  </providers>
</membership>

<roleManager enabled="true">
  <providers>
    <clear/>
    <add connectionStringName="YourSpecifiedConnectionString" // your connectionString here
         name="AspNetSqlRoleProvider"  
         applicationName="/" 
         type="System.Web.Security.SqlRoleProvider, System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>
  </providers>
</roleManager>

用于配置数据库以使用 ASP.NET内置会员提供程序,您可以使用regsql工具
可以在此处找到:

C:\Windows\Microsoft.NET\Framework\(version that you are using. mine is v4.0.30319)\

在此文件夹中,找到 aspnet_regsql.exe 文件并运行它。将显示一个有用的向导,并且
帮助您一步步配置新数据库。关于你的最后一个问题:你不必应用任何更改
到您的 edmx 文件! EF 使用您提供给它的表,并且 membershipProvider 完成其工作
ASP.NET 提供给它的表!干得好,干得好!

By default the ASP.NET membership provider uses a built-in connectionString named LocalSqlServer which is something like this:

<add name="LocalSqlServer" 
     connectionString="Data Source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|aspnetdb.mdf;User Instance=true" 
     providerName="System.Data.SqlClient"/>

and when you use the Membership for first time (or when you use the web configuration manager tool), the aspnetdb.mdf will be created automatically. For first step, you can remove this connectionString from web.config by clear command:

  <connectionStrings>
    <clear/>
    <!-- your other connectionStrings -->
  </connectionStrings>

and also, you must change the connectionString for membershipProvider (and also roleProvider if you use it) in web.config file:

<membership userIsOnlineTimeWindow="20">
  <providers>
    <clear />
    <add
         connectionStringName="YourSpecifiedConnectionString" // your connectionString here
         name="AspNetSqlMembershipProvider" 
         type="System.Web.Security.SqlMembershipProvider" 
         enablePasswordRetrieval="false" 
         enablePasswordReset="true" 
         requiresQuestionAndAnswer="false" 
         requiresUniqueEmail="false" 
         maxInvalidPasswordAttempts="500" 
         minRequiredPasswordLength="1"
         minRequiredNonalphanumericCharacters="0"
         passwordAttemptWindow="10"
         applicationName="/" />
  </providers>
</membership>

<roleManager enabled="true">
  <providers>
    <clear/>
    <add connectionStringName="YourSpecifiedConnectionString" // your connectionString here
         name="AspNetSqlRoleProvider"  
         applicationName="/" 
         type="System.Web.Security.SqlRoleProvider, System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>
  </providers>
</roleManager>

For configure the database to use ASP.NET built-in membership provider, you can use regsql tool
which can be founded here:

C:\Windows\Microsoft.NET\Framework\(version that you are using. mine is v4.0.30319)\

In this folder, find the aspnet_regsql.exe file and run it. A helpful wizard will be shown and
help you step by step to configure new database. And about your final issue: You haven't to apply any change
to your edmx file! The EF works with tables you supplied to it, and membershipProvider do its job with
tables that ASP.NET supplied to it! Well done, Good job!

苯莒 2024-12-12 20:30:13

您必须将这些表添加到您自己的数据库中。这很容易。只需使用 aspnet_regsql 工具将数据库架构导出到 SQL 文件并在您自己的数据库中运行该文件。

操作说明:
http://www .xdevsoftware.com/blog/post/Install-ASPNET-Membership-Provider-on-a-Shared-Hosting-Company.aspx

You have to add those tables to your own database. It's quite easy. Just use the aspnet_regsql tool to export the database schema to a SQL file and run that file in your own database.

Instruction:
http://www.xdevsoftware.com/blog/post/Install-ASPNET-Membership-Provider-on-a-Shared-Hosting-Company.aspx

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文