2011-12-12 70 views
0

我有一個非常基本的網站,它自己能正常工作,但是當我創建網站的副本並嘗試將其添加到子域(然後將其轉換爲應用程序)時,我嘗試使用任何控制器時出現錯誤它的頂部有以下設置:MVC 3子網站?

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似乎在抱怨在同一個域上設置了一個重複的成員資格提供程序,不確定只是重命名它將解決這個問題?任何想法讚賞,因爲我是一個新手,這是在我之上!

回答

1

我想你的「子網站」是第一個虛擬目錄。 Root的Web.config設置被繼承到虛擬目錄。

這意味着默認情況下,您的子網站將獲取在您的頂級網站中聲明的所有提供程序。

爲了防止這種行爲,你可以使用這個directiveinheritInChildApplications=false在您的主要Web.config或乾脆避免(重新)的子網站聲明EFMembershipProvider