Asp.net 在运行时覆盖成员资格设置 (asp.net mvc)
我有一个连接到 1 个数据库的应用程序。
该应用程序现在需要连接到多个数据库。我们想要做的是,使用相同的应用程序/域/主机名/虚拟目录为用户提供登录屏幕上的选项来选择他们想要连接的“应用程序/数据库”。
每个数据库都有应用程序表/数据/进程/等以及 aspnet 成员资格/角色内容。
当用户输入用户名/密码并选择(选择列表)应用程序时,我想根据所选应用程序数据库验证用户。
目前,会员服务的数据库连接字符串保存在 web.config 中。有什么办法可以在登录时覆盖它吗? 另外,我还需要“记住我”功能才能顺利工作。当用户在 5 小时内返回应用程序时,这是如何工作的......此过程应该能够识别用户和应用程序并正确登录。
I had an application that hooked onto 1 single database.
The app now needs to hook into multiple databases. What we want to do is, using the same application/domain/hostname/virtual dir give the user the option on the login screen to select the "App/Database" they want to connect into.
Each database has the App tables/data/procs/etc as well as the aspnet membership/roles stuff.
When the user enters the username/password and selects (select list) the application, I want to validate the user against the selected applications database.
Presently the database connection string for membership services is saved in the web.config. Is there any way I can override this at login time?
Also, I need the "remember me" function to work smoothly as well. How does this work when the user comes back to the app in 5 hours... This process should be able to identify the user and application and log in appropriately.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
唯一可能的方法是通过反射更改 conn 字符串:
在这里找到:
http://forums.asp.net/p/997608/2209437.aspx
为什么不直接实施您自己的会员提供商呢?非常容易做到,然后您就可以完全控制发生的事情。我确信您会想出另一种默认提供程序不能很好地工作的自定义方案。
据我所知,只要用户不删除他们的 cookie,“记住我”功能就应该完全按照您的描述工作。
The only way possible is to change the conn string via reflection:
Found here:
http://forums.asp.net/p/997608/2209437.aspx
Why not just implement your own membershipprovider? Very easy to do and then you have full control of whats happening. I'm sure you'll come up with another custom scenario the default provider doesn't work well with.
AFAIK the remember me function should work exactly how your describing as long as the user doesn't delete their cookies.
下面是一个示例的链接,该示例为您的会员提供商使用多个连接字符串。
ASP.NET 论坛 - 多个提供商
Below is a link to an example using multiple connection strings for your membership providers.
ASP.NET Forum - Multiple Providers