I need help, I'm trying to deploy my ASP.NET Core Blazor web assembly on somee, but I am having an issue on how to change my connection string while deploying to somee server. In my server project I have appsettings.json configured like this:
"ConnectionStrings": {
"DefaultConnection": "server=localhost\\sqlexpress;database=xxxxxx;trusted_connection=true"
},
while my somee connection string goes like this:
workstation id=xxxxx.mssql.somee.com;packet size=4096;user id=xxxx_SQLLogin_1;pwd=xxxx;data source=xxxx.mssql.somee.com;persist security info=False;initial catalog=xxxx
Please how do I integrate the somee connection string into my appsettings.json before deployment?
My guess is that you want to keep the SQL Express connection string when running locally and switch to the other one when running on Somee. You can use appsettings transformations for that. If you don't have a file named appsettings.production.json already, create it. Then add the following to that file:
"ConnectionStrings": {
"DefaultConnection": "workstation id=xxxxx.mssql.somee.com;packet size=4096;user id=xxxx_SQLLogin_1;pwd=xxxx;data source=xxxx.mssql.somee.com;persist security info=False;initial catalog=xxxx"
},
When publishing your web application to Somee you need to make sure that the ASPNETCORE_ENVIRONMENT environment variable is set to Production. This usually happen automatically. This will merge the changes from the appsettings.production.json file into the appsettings.json file published as part of your release. If you want to test that the update will happen as you expect it before actually deploying you can use this Appsettings.json Transformation Tester. Also, there are some additional information about how transformations work in ASP.NET Core here: Config transformations in ASP.NET Core.
Related
When I connect I have already my localhost connection string. I want to know that is there any way that I connect database to visual studio but i don't have to change connection string all the time during deployment.
Simply you can use transform file to do this. In your Solution Explore expand your Web.config file then you will see there are 2 files as
Web.Debug.config
Web.Release.config
put your development configurations and connection string in Web.Debug.config and Deployment related configurations and connection string in to Web.Release.config
then it automatically pick the config file based on your build
I'm using ASPNetBoilerplate and attempting to deploy docker images of an ASP.NET MVC/Vue.js app. The app builds and runs fine on development environments with a trusted connection to a local SQL Server. When I try to deploy to docker running on Ubuntu 20 attempting to connect to SQL Server running on a Windows 2019 Server I am consistently getting
Login failed for user '[removed]'.
Reason: Password did not mach for the login provided. [Client xxx.yyy.zzz.aaa]
I can use those exact same credentials to connect to the database server using either Azure Data Studio or SQL Server Management Studio.
It turns out that dotnet core is a bit picky about how a SQL Server is called in the connection string. I had to include the port, even though it is the standard port.
Working Connection String:
Server=172.16.0.19,1433; Database=Db; User Id=Uid; Password=Pass;
Non-working Connecting String, throwing a Login error as listed in the question:
Server=172.16.0.19; Database=Db; User Id=Uid; Password=Pass;
To Use Docker with Asp.net Boiler Plate I try this connection string and it works fro me
{
"ConnectionStrings": {
"Default": "Server=10.0.75.1,1433; Database=MyProjectDb; User ID=sa;Password=PASSWORD';Trusted_Connection=False;MultipleActiveResultSets=True;"
},
Note : 10.0.75.1 is the default docker internal switch
Both Local & Staging is working
"ConnectionStrings": {
"Default": "Server=host.docker.internal,1433; Database=ms19Db;User=sa; Password=yourStrong(!)Password;"
},
I'm part way through writing a .NET Core 3.1 Web API for a project. When I try to connect to the server, postman shows the following message:
Microsoft.Data.SqlClient.SqlException (0x80131904): Cannot open database "aspnet-53bc9b9d-9d6a-45d4-8429-2a2761773502" requested by the login. The login failed.
Login failed for user 'DESKTOP-RDBS4OR\Paul'.
I've looked around and the only things I can see are that I need to create a user for the db. I already have (the db uses the Windows Auth system) and the localdb has this user.
Looking at the throwback, I'm puzzled at the name of the DB - it's not the one in the connection string set in appsettings.json (below) or the referenced name win the StartUp class
"ConnectionStrings": {
"quizzical": "Data Source=(localdb)\\MSSQLLocalDB;Initial Catalog=quizzical;Integrated Security=True;Connect Timeout=30;Encrypt=False;TrustServerCertificate=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False"
},
Something is obviously not right, but I don't know what it is.
This is my first API I've done in .NET (I usually use php), so any tips on fixing this are appreciated.
We have an application which we are attempting to revive that was written in classic ASP in 2010. So far, I've done the following:
I created a Microsoft Server 2016 instance on Amazon EC2
I installed IIS Server
I created the website inside the IIS Manager, added/linked the files, and successfully ran the application on http://localhost
I installed SQL Server 2017 and imported the DB Backup (and successfully created the database)
I created a SQL Server user and tested that I can access the DB using the created database user
I enabled SQL Server Login Authentication and Windows Authentication Mode
I added the connection to IIS Manager.
I confirmed that web.config.xml has the proper information.
Im getting the following error:
2018-01-21 01:36:16 ::1 POST /intranet/process.asp |178|80004005|[Microsoft][ODBC_SQL_Server_Driver][DBNETLIB]SQL_Server_does_not_exist_or_access_denied. 80 - ::1
I noticed in the code theres a file that has a Session config for a database connection that doesnt look the same.
Im not sure what to do at this point. We need to figure out how to connect this database to the application
Heres my web.config.xml in the root:
<configuration>
<appSettings />
<connectionStrings>
<add connectionString="Server=server\SQLEXPRESS;Database=dbname;User ID=dbuser;Password=dbpass" name="SqlServer" />
</connectionStrings>
</configuration>
Here's my web.config.xml inside the intranet folder which is for an admin area:
<add name="WEB"
connectionString="Server=server\SQLEXPRESS;Database=dbname;User ID=dbuser;Password=dbpass"
providerName="System.Data.SqlClient" />
I noticed a file global.asa that has this:
Sub Session_OnStart
Session("ConnectString") = "Server=adifferentserver;Database=adifferentdatabase;UID=adifferentuser;PWD=adifferentpassword;Driver={SQL Server};"
This is my first time using ASP so you'd have to guide me for what other files you need.
The global.asa file in Classic ASP acts as an initialisation script it is commonplace to set long-running variables such as Application and Session variables there.
If this file contains a connection string variable then that is the value to change to your migrated database. At the moment process.asp is using Session("ConnectString") and ADODB is trying to locate adifferentserver using the SQL Server provider and failing. Once you correct the connection string using the required provider and server, database combination the page should work.
The other two values come from the web.config which was brought in with IIS 7.0 and above, it's designed for Microsoft .Net and Classic ASP does not know about connection strings configured inside it. The likelihood is there is another web application that uses ASP.Net that was making use of those connection strings.
I am trying to add a FailoverPartner to a connection string to an asp.net core application .
FailoverPartner works in connectionstrings in web.config files in asp.net eg
ConnectionString="Data Source=xxxxxxx.ad.xxxx.co.uk;Failover
Partner=yyyyyy.ad.xxxx.co.uk;Initial Catalog=DatabaseName;
Integrated Security=SSPI"
I have added basic setup for sql server to the appsettings.json and appsettings.staging.json and that is working fine eg
"ConnectionStrings": {
"DefaultConnection": "Server=XXXXXX.ad.XXXX.co.uk;Database=DatabaseName;Trusted_Connection=True;Failover Partner=yyyyyy.ad.xxxx.co.uk"
}
However adding the FailoverPartner to the end has no effect.
Is there a way of doing it?