title: System.Configuration.ConfigurationErrorsException was unhandled by user code , Message=Could not load file or assembly 'System.Web
body: <p>I have read the following article <a href="http://msdn.microsoft.com/en-us/library/ff650307.aspx" rel="nofollow">http://msdn.microsoft.com/en-us/library/ff650307.aspx</a>, about how i can authenticate asp.net mvc users from multiple domains, so inside my asp.net mvc i did the following :-</p>
  
  <p>I added the following to my web.config:-</p>
  
  <pre><code>&lt;system.web&gt;
      &lt;membership&gt;
        &lt;providers&gt;
          &lt;add name="TestDomain1ADMembershipProvider" type="System.Web.Security.ActiveDirectoryMembershipProvider, System.Web,               Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" connectionStringName="TestDomain1ConnectionString" connectionUsername="ad-domainA.intra\it360ad.user" connectionPassword="$$$$$" /&gt;
  
        &lt;/providers&gt;
      &lt;/membership&gt;
  </code></pre>
  
  <p>&amp;</p>
  
  <pre><code>&lt;connectionStrings&gt;
  
  &lt;add name="TestDomain1ConnectionString" connectionString="LDAP://ad-domainA.intra/CN=Users,DC=ad-domainA,DC=intra" /&gt;
  </code></pre>
  
  <p>and i added the following Account.controller:-</p>
  
  <pre><code>[AllowAnonymous]
          public ActionResult Login(string returnUrl)
          {
              ViewBag.ReturnUrl = returnUrl;
              return View();
          }
  
          //
          // POST: /Account/Login
  
          [HttpPost]
          [AllowAnonymous]
          [ValidateAntiForgeryToken]
          public ActionResult Login(LoginModel model, string returnUrl)
          {
  
  
              MembershipProvider domainProvider;
  
              domainProvider = Membership.Providers["TestDomain1ADMembershipProvider"];
  
  
              // Validate the user with the membership system.
              if (domainProvider.ValidateUser(model.UserName, model.Password))
              {
  
                  if (Request.QueryString["ReturnUrl"] != null)
                  {
  
                      FormsAuthentication.RedirectFromLoginPage(
                          model.UserName, false);
                  }
                  else
                  {
                      // If there is no RequestUrl query string attribute, just set
                      // the authentication cookie. Provide navigation on the login page
                      // to pages that require authentication, or user can use browser
                      // to navigate to protected pages.
                      // Set second parameter to false so cookie is not persistent
                      // across sessions.
                      FormsAuthentication.SetAuthCookie(model.UserName, false);
                  }
              }
              else
          {
  
              ModelState.AddModelError("", "The user name or password provided is incorrect.");
              return View(model);
          }
  
              return RedirectToLocal(returnUrl);
  
          }
  </code></pre>
  
  <p>but when i type my user name and password inside the login screen and click on enter , i got the following error:-</p>
  
  <blockquote>
    <p>System.Configuration.ConfigurationErrorsException was unhandled by
    user code   HResult=-2146232062   Message=Could not load file or
    assembly 'System.Web, Culture=neutral,
    PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The
    system cannot find the file specified.
    (C:\Users\john.john\Desktop\test login\TMS\TMS\web.config line 39)<br>
    Source=System.Web   BareMessage=Could not load file or assembly
    'System.Web, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one
    of its dependencies. The system cannot find the file specified.<br>
    Filename=C:\Users\john.john\Desktop\test login\TMS\TMS\web.config<br>
    Line=39   StackTrace:
           at System.Web.Security.Membership.Initialize()
           at System.Web.Security.Membership.get_Providers()   InnerException: System.IO.FileNotFoundException
           HResult=-2147024894
           Message=Could not load file or assembly 'System.Web, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its
    dependencies. The system cannot find the file specified.
           Source=mscorlib
           FileName=System.Web, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
           FusionLog==== Pre-bind state information === LOG: User = AD-ITSERVICES\john.john LOG: DisplayName = System.Web,
    Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a  (Partial) WRN:
    Partial binding information was supplied for an assembly: WRN:
    Assembly Name: System.Web, Culture=neutral,
    PublicKeyToken=b03f5f7f11d50a3a | Domain ID: 4 WRN: A partial bind
    occurs when only part of the assembly display name is provided. WRN:
    This might result in the binder loading an incorrect assembly. WRN: It
    is recommended to provide a fully specified textual identity for the
    assembly, WRN: that consists of the simple name, version, culture, and
    public key token. WRN: See whitepaper
    <a href="http://go.microsoft.com/fwlink/?LinkId=109270" rel="nofollow">http://go.microsoft.com/fwlink/?LinkId=109270</a> for more information and
    common solutions to this issue. LOG: Appbase =
    file:///C:/Users/john.john/Desktop/test login/TMS/TMS/ LOG: Initial
    PrivatePath = C:\Users\john.john\Desktop\test login\TMS\TMS\bin
    Calling assembly : (Unknown).
    === LOG: This bind starts in default load context. LOG: Using application configuration file: C:\Users\john.john\Desktop\test
    login\TMS\TMS\web.config LOG: Using host configuration file:
    C:\Users\john.john\Documents\IISExpress\config\aspnet.config LOG:
    Using machine configuration file from
    C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
    LOG: Policy not being applied to reference at this time (private,
    custom, partial, or location-based assembly bind). LOG: Attempting
    download of new URL
    file:///C:/Users/john.john/AppData/Local/Temp/2/Temporary ASP.NET
    Files/root/2fc69b03/2c0137b8/System.Web.DLL. LOG: Attempting download
    of new URL file:///C:/Users/john.john/AppData/Local/Temp/2/Temporary
    ASP.NET Files/root/2fc69b03/2c0137b8/System.Web/System.Web.DLL. LOG:
    Attempting download of new URL file:///C:/Users/john.john/Desktop/test
    login/TMS/TMS/bin/System.Web.DLL. LOG: Attempting download of new URL
    file:///C:/Users/john.john/Desktop/test
    login/TMS/TMS/bin/System.Web/System.Web.DLL. LOG: Attempting download
    of new URL file:///C:/Users/john.john/AppData/Local/Temp/2/Temporary
    ASP.NET Files/root/2fc69b03/2c0137b8/System.Web.EXE. LOG: Attempting
    download of new URL
    file:///C:/Users/john.john/AppData/Local/Temp/2/Temporary ASP.NET
    Files/root/2fc69b03/2c0137b8/System.Web/System.Web.EXE. LOG:
    Attempting download of new URL file:///C:/Users/john.john/Desktop/test
    login/TMS/TMS/bin/System.Web.EXE. LOG: Attempting download of new URL
    file:///C:/Users/john.john/Desktop/test
    login/TMS/TMS/bin/System.Web/System.Web.EXE.</p>
  
  <pre><code>   StackTrace:
          at System.RuntimeTypeHandle.GetTypeByName(String name, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly,
  </code></pre>
    
    <p>StackCrawlMarkHandle stackMark, IntPtr pPrivHostBinder, Boolean
    loadTypeFromPartialName, ObjectHandleOnStack type)
                at System.RuntimeTypeHandle.GetTypeByName(String name, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly,
    StackCrawlMark&amp; stackMark, IntPtr pPrivHostBinder, Boolean
    loadTypeFromPartialName)
                at System.RuntimeType.GetType(String typeName, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly,
    StackCrawlMark&amp; stackMark)
                at System.Type.GetType(String typeName, Boolean throwOnError, Boolean ignoreCase)
                at System.Web.Compilation.BuildManager.GetType(String typeName, Boolean throwOnError, Boolean ignoreCase)
                at System.Web.Configuration.ConfigUtil.GetType(String typeName, String propertyName, ConfigurationElement configElement,
    XmlNode node, Boolean checkAptcaBit, Boolean ignoreCase)
           InnerException:</p>
  </blockquote>
  
  <p>on the following line of code inside the Account controller:-</p>
  
  <pre><code>public ActionResult Login(LoginModel model, string returnUrl)
          {MembershipProvider domainProvider;
  domainProvider = Membership.Providers["TestDomain1ADMembershipProvider"];
  </code></pre>
  
  <p>so what is causing this error?</p>