title: Error. An error occurred while processing your request in new asp.net mvc4 error, sql server not found?
body: <p>I created a new asp.net mvc4 application.
  I created then a controller Chat and a View Chat.</p>
  
  <pre><code> public class ChatController : Controller
      {
          //
          // GET: /Chat/
  
          public ActionResult Index()
          {
              return View();
          }
  
      }
  </code></pre>
  
  <p>I wont paste the chat view, because I dont think it has nothing to do with the error.</p>
  
  <p>In the LoginPartial.cshtml I have this:</p>
  
  <pre><code>@if (Request.IsAuthenticated) {
      &lt;text&gt;
          Hello, @Html.ActionLink(User.Identity.Name, "Manage", "Account", routeValues: null, htmlAttributes: new { @class = "username", title = "Manage" })!
          @Html.ActionLink("Dashboard", "Index", "Dashboard", routeValues: null, htmlAttributes: new { id = "dashboard" })
          @Html.ActionLink("Chat", "Index", "Chat", routeValues: null, htmlAttributes: new { id = "chat" })
  
          @using (Html.BeginForm("LogOff", "Account", FormMethod.Post, new { id = "logoutForm" })) {
              @Html.AntiForgeryToken()
              &lt;a href="javascript:document.getElementById('logoutForm').submit()"&gt;Log off&lt;/a&gt;
          }
      &lt;/text&gt;
  } else {
      &lt;ul&gt;
          &lt;li&gt;@Html.ActionLink("Register", "Register", "Account", routeValues: null, htmlAttributes: new { id = "registerLink" })&lt;/li&gt;
          &lt;li&gt;@Html.ActionLink("Log in", "Login", "Account", routeValues: null, htmlAttributes: new { id = "loginLink" })&lt;/li&gt;
      &lt;/ul&gt;
  }
  </code></pre>
  
  <p>After browsing to the app and loging in, I click on chat and I get a: 
  Error. An error occurred while processing your request.</p>
  
  <p>By using NLog I got this, I dont really know what code is trying to connect to sql, because the chat controller does not have any server side code to do any query</p>
  
  <pre><code>04/10/2013 20:17:44: System.Web.HttpException (0x80004005): Unable to connect to SQL Server database. ---&gt; System.Data.SqlClient.SqlException (0x80131904): A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)
     at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)
     at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose)
     at System.Data.SqlClient.TdsParser.Connect(ServerInfo serverInfo, SqlInternalConnectionTds connHandler, Boolean ignoreSniOpenTimeout, Int64 timerExpire, Boolean encrypt, Boolean trustServerCert, Boolean integratedSecurity, Boolean withFailover)
     at System.Data.SqlClient.SqlInternalConnectionTds.AttemptOneLogin(ServerInfo serverInfo, String newPassword, SecureString newSecurePassword, Boolean ignoreSniOpenTimeout, TimeoutTimer timeout, Boolean withFailover)
     at System.Data.SqlClient.SqlInternalConnectionTds.LoginNoFailover(ServerInfo serverInfo, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString connectionOptions, SqlCredential credential, TimeoutTimer timeout)
     at System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(TimeoutTimer timeout, SqlConnectionString connectionOptions, SqlCredential credential, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance)
     at System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, SqlCredential credential, Object providerInfo, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString userConnectionOptions)
     at System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, DbConnectionPoolKey poolKey, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection, DbConnectionOptions userOptions)
     at System.Data.ProviderBase.DbConnectionFactory.CreateNonPooledConnection(DbConnection owningConnection, DbConnectionPoolGroup poolGroup, DbConnectionOptions userOptions)
     at System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal&amp; connection)
     at System.Data.ProviderBase.DbConnectionClosed.TryOpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions)
     at System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource`1 retry)
     at System.Data.SqlClient.SqlConnection.Open()
     at System.Web.Management.SqlServices.GetSqlConnection(String server, String user, String password, Boolean trusted, String connectionString)
  ClientConnectionId:00000000-0000-0000-0000-000000000000
     at System.Web.Management.SqlServices.GetSqlConnection(String server, String user, String password, Boolean trusted, String connectionString)
     at System.Web.Management.SqlServices.SetupApplicationServices(String server, String user, String password, Boolean trusted, String connectionString, String database, String dbFileName, SqlFeatures features, Boolean install)
     at System.Web.Management.SqlServices.Install(String database, String dbFileName, String connectionString)
     at System.Web.DataAccess.SqlConnectionHelper.CreateMdfFile(String fullFileName, String dataDir, String connectionString)
     at System.Web.DataAccess.SqlConnectionHelper.EnsureDBFile(String connectionString)
     at System.Web.DataAccess.SqlConnectionHelper.GetConnection(String connectionString, Boolean revertImpersonation)
     at System.Web.Security.SqlRoleProvider.GetRolesForUser(String username)
     at WebMatrix.WebData.SimpleRoleProvider.GetRolesForUser(String username)
     at System.Web.Security.RolePrincipal.IsInRole(String role)
     at System.Web.Configuration.AuthorizationRule.IsTheUserInAnyRole(StringCollection roles, IPrincipal principal)
     at System.Web.Configuration.AuthorizationRule.IsUserAllowed(IPrincipal user, String verb)
     at System.Web.Configuration.AuthorizationRuleCollection.IsUserAllowed(IPrincipal user, String verb)
     at System.Web.Security.UrlAuthorizationModule.OnEnter(Object source, EventArgs eventArgs)
     at System.Web.HttpApplication.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
     at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean&amp; completedSynchronously)
  </code></pre>
  
  <p>the web.config has this, I checked the App_data folder and the MDF file is there.</p>
  
  <pre><code>&lt;connectionStrings&gt;
      &lt;add name="DefaultConnection" connectionString="Data Source=(LocalDb)\v11.0;Initial Catalog=aspnet-FullStackSampleApplication-20130404120217;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\aspnet-FullStackSampleApplication-20130404120217.mdf" providerName="System.Data.SqlClient" /&gt;
    &lt;/connectionStrings&gt;
  </code></pre>
  
  <p><strong>UPDATE:</strong>
  By checking my web.config, I see that elmah.axd is protected depending on users and roles, but there is no role provider anywhere,</p>
  
  <pre><code>  &lt;location path="elmah.axd" inheritInChildApplications="false"&gt;
      &lt;system.web&gt;
        &lt;httpHandlers&gt;
          &lt;add verb="POST,GET,HEAD" path="elmah.axd" type="Elmah.ErrorLogPageFactory, Elmah" /&gt;
        &lt;/httpHandlers&gt;
        &lt;authorization&gt;
          &lt;allow roles="admin" /&gt;
          &lt;allow users="levalencia" /&gt;
          &lt;deny users="*" /&gt;
        &lt;/authorization&gt;
      &lt;/system.web&gt;
      &lt;system.webServer&gt;
        &lt;handlers&gt;
          &lt;add name="ELMAH" verb="POST,GET,HEAD" path="elmah.axd" type="Elmah.ErrorLogPageFactory, Elmah" preCondition="integratedMode" /&gt;
        &lt;/handlers&gt;
      &lt;/system.webServer&gt;
    &lt;/location&gt;
  </code></pre>