ASP.Net MVC 按区域成员资格
我正在构建一个 ASP.Net MVC 应用程序,它将在共享托管帐户上运行以托管多个域。我从包含成员资格的默认模板开始,并为每个域创建了一个 mvc 区域。路由设置为根据请求所针对的域指向正确的区域。现在我想设置特定于每个 mvc 区域的成员资格。我首先尝试了显而易见的方法,并尝试覆盖每个区域的 web.config 部分以更改提供程序的 applicationName 属性。这不起作用,因为该区域未设置为应用程序根目录。有没有一种简单的方法来区分每个区域的用户?
I am building an ASP.Net MVC app that will run on a shared hosting account to host multiple domains. I started with the default template that includes membership and created an mvc area for each domain. Routing is set up to point to the correct area depending on the domain the request is for. Now I would like to set up membership specific to each mvc area. I tried the obvious first and attempted to override the section of the web.config for each area to change the applicationName attribute of the provider. That doesn't work since the area is not set up as an application root. Is there an easy way to separate the users for each area?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我想我有一个可行的解决方案,可以使每个区域完全分开。使用默认模板作为起点,我向 MvcApplication1.Models.AccountMembershipService 类添加了另一个构造函数以接受字符串(还修改了现有构造函数以消除歧义)。
然后,我将 AccountController 复制到每个区域中,并修改了初始化重载以包含路线数据中的区域名称。
现在,每个区域都在表单身份验证下注册为新应用程序,并且所有用户和角色应保持独立。
I think I have a working solution that keeps each area completely separate. Using the default template as a starting point I added another constructor to the MvcApplication1.Models.AccountMembershipService class to accept a string (Also modified the existing constructors to eliminate ambiguity).
Then I copied the AccountController into each area and modified the Initialize overload to include the area name from the route data.
Now each area is registered as a new application under forms authentication and all users and roles should be kept separate.