Asp.net mvc 3 MVC3子站点?
我有一个非常基本的站点,它本身可以正常工作,但当我创建站点的副本并尝试将其添加到子域(然后将其转换为应用程序)时,当我尝试添加到顶部具有以下设置的任何控制器时,会出现错误:Asp.net mvc 3 MVC3子站点?,asp.net-mvc-3,iis-7,Asp.net Mvc 3,Iis 7,我有一个非常基本的站点,它本身可以正常工作,但当我创建站点的副本并尝试将其添加到子域(然后将其转换为应用程序)时,当我尝试添加到顶部具有以下设置的任何控制器时,会出现错误: public class AccountController : Controller { // This constructor is used by the MVC framework to instantiate the controller using // the default forms au
public class AccountController : Controller
{
// This constructor is used by the MVC framework to instantiate the controller using
// the default forms authentication and membership providers.
private CustomMembershipDB datacontext;
public AccountController()
: this(null, null)
{
datacontext = new CustomMembershipDB();
}
// This constructor is not used by the MVC framework but is instead provided for ease
// of unit testing this type. See the comments at the end of this file for more
// information.
public AccountController(IFormsAuthentication formsAuth, IMembershipService service)
{
FormsAuth = formsAuth ?? new FormsAuthenticationService();
MembershipService = service ?? new AccountMembershipService();
}
public IFormsAuthentication FormsAuth
{
get;
private set;
}
public IMembershipService MembershipService
{
get;
private set;
}
我得到的错误是:
描述:处理服务此请求所需的配置文件时出错。请查看下面的特定错误详细信息,并适当修改配置文件
分析器错误消息:已添加条目“EFMembershipProvider”
IIS似乎在抱怨在同一个域上设置了重复的成员资格提供程序,并且不确定简单地重命名它就能解决这个问题?我是个新手,任何想法都值得欣赏,这比我高明 我假设您的“子网站”是第一个网站的虚拟目录。Root的Web.config
设置继承到虚拟目录
这意味着默认情况下,您的子网站将获得顶级网站中声明的所有提供者
要防止此行为,您可以在主Web.config
上使用此inheritInChildApplications=false
,也可以避免(重新)在子网站中声明EFMembershipProvider