Created a project using the MVC template, added the DataBase folder with the UserStore.mdf database to the App_Data folder. I decided to connect to it and an exception was thrown with the text: Недопустимое значение ключа "attachdbfilename". . I checked the file path, did it by example .
<connectionStrings> <add name="userStore" connectionString="Data Source=localhost\SQLEXPRESS;Integrated security=SSPI;AttachDBFilename=|DataDirectory|\DataBase\UserStore.mdf;User Instance=True"/> </connectionStrings> Connection I wrote in Global.asax
protected void Application_Start() { AreaRegistration.RegisterAllAreas(); RouteConfig.RegisterRoutes(RouteTable.Routes); string connectionString = WebConfigurationManager.ConnectionStrings["userStore"].ConnectionString; System.Data.SqlClient.SqlConnection con = new System.Data.SqlClient.SqlConnection(connectionString);//Вот тут исключение ArgumentException con.Open(); } 