Visual Studio 2017 - Web Deploy - connection string problem - asp.net-mvc

My issue with Web Deploy that a connection string formatted as follow in the setting:
metadata=res://*/Model1.csdl|res://*/Model1.ssdl|res://*/Model1.msl;provider=System.Data.SqlClient;provider connection string="data source=.\MSSQLSERVER2012;initial catalog=myDataBase;persist security info=True;user id=myUser;password=myPassoword;multipleactiveresultsets=True;application name=EntityFramework"
Is somehow not considered and not sent to the web, and the deploy use the local connection string instead... that are almost same except server name...
Note: when Deploy a connection string that like this, its working normally and the web.config is correctly Deployed :
data source=.\MSSQLSERVER2012;initial catalog=myDataBase;persist security info=True;user id=myUser;password=myPassoword;MultipleActiveResultSets=True;App=EntityFramework
I suspect that the syntax starting with metadata=res: is not accepted on Web Deploy, but I don't know how to solve it, thank you.
Edit:
I found that the file used to change web.config is CSAutoParameterize.parameters.xml I edited it, that's works, but back to same issue after rebuild... maybe is a bug?

Finally i found where the problem come from...
The Web Deploy save his setting on a file with extension .pubxml his name is same as the name that you give to your web deploy profile, located in \My Project\PublishProfiles\
When you past in the setting dialog a connection string that contain some " the saved connection string became different, i don't know why ... So I just modify manually this file with correct value, I just have to keep in mind to modify it again if I change my Publish setting, but actually is not something that you change often.

Related

Application Settings in Azure Portal not Overwriting Generic Values

This is my process for setting some connection strings in my Azure hosted app:
When debugging, the strings are stored in Web.Config as normal, and this is encrypted with aspnet_regiis to hide them in the version control.
At publish, these are set to some generic values in Web.Release.Config:
<add xdt:Transform="Insert" name="SPsvcUsername" connectionString="username"/>
<add xdt:Transform="Insert" name="SPsvcPassword" connectionString="password"/>
I then go into the App Service on the Azure portal and under Application Settings -> Connection Strings I add the actual values required, just using the same name, e.g. SPsvcUsername. This overwrites the generic values and everything is fine and dandy.
This has always worked since I started doing it and I have had 0 issues apart from ocasionally I would have to wait a couple of minutes for it to update.
However, today it just doesn't apply the settings that I input in Azure Portal.
When I go into the command prompt and call
more web.config
I can see that the connection string scontains the generic values username and password
What gives? Why did this suddenly stop working? Was there an update that addressed this that I haven't read about?
Any advice is much appreciated. Including anything on whether my original process actually makes any sense.
They are replaced at runtime, not in the file.
So when you access the connection string via:
string username = ConfigurationManager.ConnectionStrings["SPsvcUsername"].ConnectionString;
It will have the value from the Application Settings blade.

Umbraco cannot start. A connection string is configured but the Umbraco cannot connect to the database

I'm using Umbraco CMS v7.4 with SQL Server 2014, the project was working fine until a few hours ago, when an error started showing up:
Umbraco cannot start. A connection string is configured but the Umbraco cannot connect to the database
The error occurs when I tried to open the website, see the image below:
I tried the following:
Checked to see if SQL Server is running
Checked the connection string credentials in web.config
Any help is appreciated.
After a few tries, even I loaded the backed up DB, I found that it caused by the DB login, the user in the connection string was having a password expiration enabled (the password had expired).
So, this is what I did:
Open the SQL server
Logged in as the user used in the connection string
Created a new password
Updated the web.config connection string "Password"
Hope this will help
So, in my case I tried to get started with the existing project. I got all the files, restored DB backup locally, made sure all permissions are set for IIS AppPool user etc. But I kept getting the error in question. It turns out that I cannot use server=localhost;database=... in connection string. After I replaced it with server=.\;database=..., it started to work right away.
Also note that if you're running it in Azure with an Azure SQL database you'll have to go to the Azure SQL Server settings and under "Firewalls and virtual networks" you'll need to tick "Yes" for "Allow Azure services and resources to access this server".
I was getting this error when running an Umbraco project locally, with the DB pointing to an instance on Azure. In that case, this problem happens if you haven't allowed the IP access within the Server Firewall of the DB in Azure.
You can fix this by finding out your IP and then adding it to the DB:
Click All Resources within your Azure portal, then click on the SQL Database your project points to.
Click Set Server Firewall on the right-side window.
Add in your IP as the start and end points, and call it something memorable.
Click Save and once you get the confirmation message that It has been applied, refresh your site locally.
I experienced the same problem and here is how I fixed it.
Right-click on your localhost in SSMS and select Properties
Got to the Security page and select "Select authentication" as "SQL Server and Windows Authentication mode"
Hit OK.
Go to Services and find your SQL Server service and restart it.
Check your local umbraco website now, you should be able to see it without any issues. If you still have problems, then you might need to check your local setup and permissions.
Further details are below and on this blog post.

Umbraco installation wizard Error - Could not connect to database

I'm trying to install Umbraco on an ASP.NET environment. After I downloaded the umbraco nuget package I tried to run the installation wizard, by building and running the project. All is fine and good, if i take the default database configuration, but if I want to customize my configuration, it fails and says :
"Could not connect to database"
I'm trying to configure it to use my local SQLExpress database, but I just cannot get it working. I have both tried putting in the server information and connecting via. a connection string, via. the wizard. It produces the same error every time.
I have made a database called umbracoblog and created an admin user, with credentials. He has dbowner etc. for the database. Besides that, I have also given full permissions to IIS_IUSRS and Network Service accounts for the project and all subdirectories, and it still doesn't work.
These are some of the connection strings I have tried:
datalayer=SqlServer;Data Source=.\SQLExpress;Initial Catalog=umbracoblog;User Id=admin;Password=********;
datalayer=SqlServer;Data Source=127.0.0.1\SQLExpress;Initial Catalog=umbracoblog;User Id=admin;Password=*******;
I have also tried putting in the connectionstring into the web.config, manually, but that just makes the project load infinitely in the browser, when I run it.
It's starting to get frustrating, that I cannot even get past the configuration of Umbraco, because it look very cool. I have tried everything I was able to found online. Have anyone gone through this and know what I need to do ?
Start again - clear out and remove the umbracoDbDSN connection string entirely from your web.config and reset the umbracoConfigurationStatus AppSetting back to empty if it has been populated.
Use the Wizard to configure the database - if it's still having problems connecting then here's a few things to check:
Check the Log file here: ~/App_Settings/Logs/UmbracoTraceLog.txt - does that show up any errors?
Make sure you can connect to the database using other clients - if Umbraco can't connect to it, chances are something else won't be able to as well.
What happens if you use Integrated Authentication? If that works, then it's most likely an issue with the username and password you specified.
The password I had for the SQL Server user had a character that the installation UI didn't accept. I changed the password to remove special characters and it was able to connect to the server again. I could successfully log in through SSMS with the previous password.

LocalDB and Entity Framework 6 - Security

I am trying to figure out a way to use a LocalDB in place of SQL for integration testing of EF6 queries (this would allow us to run integration tests on our build server). It seems like I should be able to replicate my database in SQL Express, detach, and import into my test project.
I would expect from there I can modify my connection string in my test project to hit the local database file. I am running into a security issue though. I need to get SQL security working to pass in a user id and password in my conn string (since the build server will not be using my domain account), but regardless of what I try I get a bad username or password error as soon as I try to query. My connection string looks like this:
<add name="ClinicalContext" connectionString="metadata=res://*/ClinicalDataStore.csdl|res://*/ClinicalDataStore.ssdl|res://*/ClinicalDataStore.msl;provider=System.Data.SqlClient;provider connection string="Data Source=(LocalDB)\v11.0;AttachDbFilename=|DataDirectory|\ClinicalDataStore.mdf;Integrated Security=False;User Id=SomeUser;Password=SomeUsersPassword;""
providerName="System.Data.EntityClient" />
Does anyone have any experience with this and know if I need to do something particular to get sql security to work this way?
Update
I attached the database file via Server Explorer and checked the updated connection string. The only change was to add an Initial Catalog and change the security back to integrated. If I try to connect that way, I get an error that it cannot access the catalog as the defined name. If I change back to sql security I still get the bad username or password error.

Umbraco + YAF integration - connection issues

I'm working to try and get a migrated Umbraco/YAF installation working, but I'm having issues with connectivity.
I've already asked for help with the Connection Strings, so this bit is sorted.
However, I still get a 404 error when I try and navigate to mysite/forums, as it redirects to mysite/install
This site tells me that this could be because of a few issues:
It will connect you to install\default.aspx if
: its connect to a db but thinks there isn't a YAF version present in its data, or
: database version doesn't match and thinks it needs updating.
I know it's connecting to the DB, because the CMS connection string works, and it's connecting to the same database.
There are YAF_* tables in the database, so I know it's content is there.
By process of elimination, it might be a version issue, but I'm not sure how to compare the DB version to the ASP files version.
I'm running Umbraco 4.6.1
I never quite worked out what version I was running, but I did find out this issue was fixed by:
Assign yaf database user db-owner privileges.
And there you have it.
check that you have the following line in web.config
<add key="umbracoConfigurationStatus" value="4.6.1" />

Resources