title: Deploying web application that uses Asp.NET Membership database throws error on Login and Register
body: <p>I posted a question a few days ago about a Win32 Exception error about the parameter was incorrect when deploying to godaddy, that link is <a href="https://stackoverflow.com/questions/30987167/win32-exception-error-the-parameter-was-incorrect-after-deploying-to-godaddy">here</a>
  Well after some more digging around, I thought I had figured out the issue because what I was trying to do was not only deploy the web app (which I have successfully done) but also deploy the asp.net membership database that gets created when creating a project and using the Webforms template in VS2013.
  So I found some tutorials on this <a href="https://msdn.microsoft.com/en-us/library/vstudio/ff361972(v=vs.100).aspx" rel="nofollow noreferrer">here</a> and <a href="https://msdn.microsoft.com/en-us/library/vstudio/dd465343(v=vs.100).aspx" rel="nofollow noreferrer">here</a>
  So after following and trying both, I am still getting the same error that I mentioned in my original question. I took a look at the webconfig and noticed this connectionstring</p>
  
  <pre><code>&lt;add name="DefaultConnection" connectionString="Data Source=(LocalDb)\v11.0;AttachDbFilename=|DataDirectory|\aspnet-GSDataCollection-20150421103634.mdf;Initial Catalog=aspnet-GSDataCollection-20150421103634;Integrated Security=True" providerName="System.Data.SqlClient" /&gt;
  </code></pre>
  
  <p>This was created when I created the project. I commented that out because I generated scripts from SSMS with schema and data, and ran it against the shared database and then added this connectionstring</p>
  
  <pre><code>&lt;add name="DefaultConnection" connectionString="Data Source=*****:1433;Initial Catalog=*****;Persist Security Info=True;User ID=*****;Password=*****" providerName="System.Data.SqlClient" /&gt;
  </code></pre>
  
  <p>this is the connectionstring that I use to connect to the database through SSMS and was provided when I opened the database in the Server Explorer of Visual Studio and got it from right clicking the database and clicking properties then copied it over from properties area.
  So next I went back to SSMS and queried the table to make sure that there was data in the AspNetUsers table and there was. So after a number of failed attempts at registering on the site and getting the same Win32 Exception error, I decided to go into the App_Data folder and published the database and thought maybe that was the issue and no, didn't work again.</p>
  
  <p>So I thought that maybe that I may have done something wrong and wrote a test app to see if I could connect to the database and just wrote this</p>
  
  <pre><code>string cnStr = ConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString;
  SqlConnection cn = new SqlConnection(cnStr);
  
  string cmStr = "SELECT * FROM AspNetUsers";
  SqlCommand cm = new SqlCommand(cmStr, cn);
  cm.CommandType = CommandType.Text;
  
  DataSet ds = new DataSet();
  SqlDataAdapter da = new SqlDataAdapter(cm);
  
  cn.Open();
  da.Fill(ds);
  cn.Close();
  </code></pre>
  
  <p>I set a break point at da.fill(ds); and it threw the exact same error as it did from my original project and that error is</p>
  
  <blockquote>
    <p>Additional information: 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: 25 - Connection string is not valid)</p>
  </blockquote>
  
  <p>So I am pretty lost now on what to do or try, and am still waiting on a response from GoDaddy. Has anyone had any issues on deploying a web application that uses asp.net membership database? or does anyone notice where I may have went wrong?</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>Here is the entire IdentityModel with the DbContext</p>
  
  <pre><code>    using System;
  using System.Security.Claims;
  using System.Threading.Tasks;
  using System.Web;
  using Microsoft.AspNet.Identity;
  using Microsoft.AspNet.Identity.EntityFramework;
  using Microsoft.AspNet.Identity.Owin;
  using Microsoft.Owin.Security;
  using GSDataCollection.Models;
  
  namespace GSDataCollection.Models
  {
  // You can add User data for the user by adding more properties to your User class, please visit http://go.microsoft.com/fwlink/?LinkID=317594 to learn more.
  public class ApplicationUser : IdentityUser
  {
      public ClaimsIdentity GenerateUserIdentity(ApplicationUserManager manager)
      {
          // Note the authenticationType must match the one defined in CookieAuthenticationOptions.AuthenticationType
          var userIdentity = manager.CreateIdentity(this, DefaultAuthenticationTypes.ApplicationCookie);
          // Add custom user claims here
          return userIdentity;
      }
  
      public Task&lt;ClaimsIdentity&gt; GenerateUserIdentityAsync(ApplicationUserManager manager)
      {
          return Task.FromResult(GenerateUserIdentity(manager));
      }
  }
  
  public class ApplicationDbContext : IdentityDbContext&lt;ApplicationUser&gt;
  {
      public ApplicationDbContext()
          : base("DefaultConnection", throwIfV1Schema: false)
      {
      }
  
      public static ApplicationDbContext Create()
      {
          return new ApplicationDbContext();
      }
  }
  }
  
  #region Helpers
  namespace GSDataCollection
  {
  public static class IdentityHelper
  {
      // Used for XSRF when linking external logins
      public const string XsrfKey = "XsrfId";
  
      public static void SignIn(ApplicationUserManager manager, ApplicationUser user, bool isPersistent)
      {
          IAuthenticationManager authenticationManager = HttpContext.Current.GetOwinContext().Authentication;
          authenticationManager.SignOut(DefaultAuthenticationTypes.ExternalCookie);
          var identity = manager.CreateIdentity(user, DefaultAuthenticationTypes.ApplicationCookie);
          authenticationManager.SignIn(new AuthenticationProperties() { IsPersistent = isPersistent }, identity);
      }
  
      public const string ProviderNameKey = "providerName";
      public static string GetProviderNameFromRequest(HttpRequest request)
      {
          return request.QueryString[ProviderNameKey];
      }
  
      public const string CodeKey = "code";
      public static string GetCodeFromRequest(HttpRequest request)
      {
          return request.QueryString[CodeKey];
      }
  
      public const string UserIdKey = "userId";
      public static string GetUserIdFromRequest(HttpRequest request)
      {
          return HttpUtility.UrlDecode(request.QueryString[UserIdKey]);
      }
  
      public static string GetResetPasswordRedirectUrl(string code, HttpRequest request)
      {
          var absoluteUri = "/Account/ResetPassword?" + CodeKey + "=" + HttpUtility.UrlEncode(code);
          return new Uri(request.Url, absoluteUri).AbsoluteUri.ToString();
      }
  
      public static string GetUserConfirmationRedirectUrl(string code, string userId, HttpRequest request)
      {
          var absoluteUri = "/Account/Confirm?" + CodeKey + "=" + HttpUtility.UrlEncode(code) + "&amp;" + UserIdKey + "=" + HttpUtility.UrlEncode(userId);
          return new Uri(request.Url, absoluteUri).AbsoluteUri.ToString();
      }
  
      private static bool IsLocalUrl(string url)
      {
          return !string.IsNullOrEmpty(url) &amp;&amp; ((url[0] == '/' &amp;&amp; (url.Length == 1 || (url[1] != '/' &amp;&amp; url[1] != '\\'))) || (url.Length &gt; 1 &amp;&amp; url[0] == '~' &amp;&amp; url[1] == '/'));
      }
  
      public static void RedirectToReturnUrl(string returnUrl, HttpResponse response)
      {
          if (!String.IsNullOrEmpty(returnUrl) &amp;&amp; IsLocalUrl(returnUrl))
          {
              response.Redirect(returnUrl);
          }
          else
          {
              response.Redirect("~/");
          }
      }
  }
  }
  #endregion
  </code></pre>