We have an old application that was built years ago by people no one know. Now we are running a project to disable TLS 1.0 & 1.1 globally in our environment and of course this application stops working. The problem is that the application is using old OLEDB driver to connect to it's database hosted on a MSSQL server 2017.
The application itself connects to it's database to create financial reports and is crucial in book endings for that region.
It consist of 2 files, one application file which is basically only executionable and one config file.
This is what the config file consist of:
<?xml version="1.0" encoding="utf-8"?>
<Configuration>
<Section name="Parameters">
<Item key="CompanyID" value="XX" />
<Item key="Company_Name" value="Company Name" />
<Item key="ServerIp" value="SQLSERVER" />
<Item key="DbName" value="DATABASE" />
<Item key="UserID" value="SQLLOGIN" />
<Item key="UserPass" value="Password" />
</Section>
</Configuration>
I've tried to check within the application settings if it's possible to change driver but there's no such option. There's nothing in the registry that tells the application what driver to use. It's not using an existing ODBC connection.
I was thinking that it might be possible to add a line in the config file telling the application what driver to use when connecting to the database but don't have the knowledge for it nor have I found it while searching around online.
Related
I have an asp.net core 2.1 website running on a windows server as an azure web app. I was asked to enable "keep-alive" so that when a client asks for "Connection:Keep-Alive" the connection is NOT closed. I cant find any documentation on how to do this (nor if this is even possible).
The reason for getting a persistent connection (if this is the correct term) is to reduce the overhead from the SSL negotiation.
I did find this: Azure Website Connection Keep-Alive stack-overflow question. The provided answer doesn't help. There is no web.config file in asp.net core web apps. i didn't find anything else regarding Keep-Alive in asp.net core.
Actually, there will still be a web.config file for IIS in web app. After you publish your .NET Core web app, you can use Azure Kudu tools from portal to checks files, and you will find the web.config generated by system.
So, you can manually add a web.config file in your project:
And then choose web configuration file
Then, you can add your configurations:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.webServer>
<httpProtocol allowKeepAlive="true" />
</system.webServer>
</configuration>
Finally, deploy your project, and configurations will be updated in kudu:
I am having a problem with Web Deploy packages recognizing SQL. I am using Visual Studio 2015, SQL Server 2014, SSDT Database Project. The workflow is, create a MVC project, create a Database project, and use the Web Deploy Package to run SQL queries on the DB project. I plan to Publish the MVC project into a web deploy package and add queries to the deployment as part of the package. (I am not trying DACPACs at the moment because I ran into issues where they were not including pre and post deployment scripts in them when using Web Deploy Tool).
The problem happens when publishing a web deploy package using the connection string below.
<connectionStrings configSource="connectionsettings.config">
That in the web.config prevents web deploy from detecting a database to add to the web package for web deploy packaging.
deloy package missing database
Whenever I change to a normal connection string, even something as simple as this:
<connectionStrings>
<add name="Default" connectionString="" providerName="System.Data.SqlClient" />
Then web deployment package works and you get the proper UI.
deloy package working
Anyone know how to get the database to show up using a configsource in the web.config connectionstrings? As an alternative, I was looking into getting parameters.xml to replace the blank connection string to include the configSource above, but have had no luck.
The idea was to remove the Default connection and replace it with the config source. Removing the default connection works but the configSource does not.
<parameter name="RemoveConnectionString" defaultValue="">
<parameterValidation kind="AllowEmpty" />
<parameterEntry kind="XmlFile"
scope="Web\.config$"
match="//configuration/connectionStrings/add[#name='Default']" />
</parameter>
<parameter name="AddConfigSource" defaultValue="connectionsettings.config">
<parameterEntry kind="XmlFile"
scope="\\web.config$"
match="/configuration/connectionStrings/#configSource" />
</parameter>
Web Deploy Package seems undeveloped for SQL, but is there a fix for my issue or a better way to do an all-in-one deploy for IIS & SQL?
Use WebDeploy Parameterization to manually create parameters for the separate config file.
Skip down to "Step 3 - Create a parameter file" in the following link:
http://www.iis.net/learn/publish/using-web-deploy/web-deploy-parameterization
This may also be helpful:
http://www.dotnetcatch.com/2014/09/08/parameterizationpreview-visual-studio-extension/
This is my second deployment to Azure.
First was a simple MVC4 Website with a Database, which I deployed via git. Worked like a charm.
Now I've got the following:
A solution containing three projects.
Web -> Which is the MVC4 Frontend
Models -> Contains the Models and the DB Context
Backend -> MVC4 Project for data administration
All projects are MVC4 (didn't know how to manage this better for the Models project).
In my models project I'm running the code-firt migrations.
The backend is running in the virtual directory: localhost:80/Backend
(works perfect on localhost)
Both the Web and Backend project have references to the Models Project.
Folder structure:
Solution folder contains:
Web / Models / Backend / MySolution.sln
The first time I deployed I've created a git repo in the Projects folder (cause it was a single project). Now my repo is in the solution folder.
I'm also uploading files in the Backend and move it to the other project (Web) via the following path:
Directory.GetParent(HttpContext.Current.Server.MapPath("~")).ToString() + DirSeperator + "Web" + DirSeperator + "Store" + DirSeperator;
Is this going to a problem on Azure?
So my loose question is now, how am I deploying this solution?
I've created a Website with Source control in Azure and added a SQL Database to it.
I've managed to push the solution to Azure,
but on Azure there's the messsage
Found solution ... with no deployable projects. Deploying files instead.
now.
Do you have any good tutorials for me on this problem?
Am I doing it completely wrong? (I think so)
I'm relatively new to ASP.NET and Azure, so it's a bit hard for me to understand.
Thanks,
Tobi
Followup Edit: I see now, this has more to do with configuring 2 project deploys. You will need to create deployment scripts
I'm not done doing research, but take a look at these posts:
http://blog.amitapple.com/post/38419111245/azurewebsitecustomdeploymentpart3
http://kellyhpdx.wordpress.com/2012/04/11/deploying-multiple-web-applications-to-a-single-azure-instance-and-applying-web-config-transforms-correctly/
I've managed to solve my problem.
Sorry, that I'm answering my own question - hope this doesn't offend anyone.
What I wanted to achieve is not possible with Azure Web Sites, but with Web Roles.
As seen here on CloudCover and on StructureTooBig.
So I've created a new Azure Cloud Application (provided by the Azure Tools) in Visual Studio, with a default Web Role, which is my Web Frontend project.
I've added a VirtualApplication to the Web Role with the name "backend" and the physicalDirectory set to my Backend Project path.
Then I've added a VirtualDirectory "store", which I could access from both projects for file uploads.
My WebRole looks like this now:
<WebRole name="MvcWebRole1" vmsize="ExtraSmall">
<Sites>
<Site name="Web" physicalDirectory="[projectpath]">
<VirtualApplication name="backend" physicalDirectory="[projectpath]">
</VirtualApplication>
<VirtualDirectory name="store" physicalDirectory="[projectpath]">
</VirtualDirectory>
<Bindings>
<Binding name="Endpoint1" endpointName="Endpoint1" />
</Bindings>
</Site>
</Sites>
<Endpoints>
<InputEndpoint name="Endpoint1" protocol="http" port="80" />
</Endpoints>
<Imports>
<Import moduleName="Diagnostics" />
<Import moduleName="RemoteAccess" />
<Import moduleName="RemoteForwarder" />
</Imports>
I'm accessing (read+write) the store now via:
HttpContext.Current.Request.MapPath("/Store" + DirSeperator);
instead of
Directory.GetParent(HttpContext.Current.Server.MapPath("~")).ToString() + DirSeperator + "Web" + DirSeperator + "Store" + DirSeperator;
Which works perfectly on both projects.
So, this solution works and I've already deployed it to production!
Emerging problems:
Web Sites work with git integration, but Cloud Services won't (this is very bad for my workflow).
The deployment takes about 30-45 minutes. Holy ...
I've had to publish everything again to activate Remote Access and WebDeploy features. And I hope, WebDeploy is going to save time for deploying updates ... as everytime I'm updating now, the complete solution is replaced on server (within the mentioned time span).
Is there a way to access the data via FTP?
Ciao
I have an ASP.NET Web Application project that connects to a remote database via the Entity Framework. During debugging (eg running the project on my local computer), the IP address to the database is different than during release (eg after uploading the project to my webserver and running it from the browser). Until now I have always manually changed the database connection string in the Web.config file to switch between the two (basically I had to connection strings, one named 'Debug' and one 'Release' and I just swapped around the names whenever I deployed).
Now I just noticed that it should be possible to let this happen automatically via the Web.config Transformation Syntax where you put the modified connection string in the Web.Release.config version and it should then use that when the DLL is built under Release configuration.
However it does not seem to work for me...
Here is the relevant part of my regular Web.config file (which holds the Debug connection string for local usage):
<?xml version="1.0"?>
<configuration>
<connectionStrings>
<!-- Debug connection string. Release connection string is in Web.Release.config file -->
<add name="DatabaseEntities" connectionString="A" providerName="System.Data.EntityClient" />
</connectionStrings>
</configuration>
Here is the Web.Release.config file, which according to the examples should replace the 'DatabaseEntities' connection string "A" with "B" if the DLL is under Release mode:
<?xml version="1.0"?>
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<!-- Replace the DatabaseEntities connection string with the Release version (local IP address) -->
<connectionStrings>
<add name="DatabaseEntities"
connectionString="B"
xdt:Transform="Replace" xdt:Locator="Match(name)"/>
</connectionStrings>
</configuration>
(Obviously "A" and "B" are just place-holders for my real connection strings)
When I debug the application (e.g. just press F5) the default Web.config is used and I can access the database. I then change the build configuration to Release via the Configuration Manager. All the projects in the solution are set to Release configuration. Then I Build the solution (just via Build or even via a complete rebuild (e.g. Clean, Rebuild)). I upload the newly built DLLs to the webserver, as well as the Web.config and Web.Release.config files, and when I try to access the database I am unable, it is still trying to access the database via the debug IP address and hence cannot find it...
It seems the Web.Release.config file is completely ignored, or at least the connection string is not being replaced.
What am I doing wrong? Is the transformation syntax wrong? Am I not building the application under Release mode correctly?
Then I Build the solution (just via Build or even via a complete
rebuild (e.g. Clean, Rebuild)). I upload the newly built DLLs to the
webserver, as well as the Web.config and Web.Release.config files
There is your error: Web config transforms won't work for your local environment, if you simply build. You need to publish.
Your deployment process seems weird: You are only copying DLLs, Web.config and web.Release.config. To me it seems, that you copy your source code and not a compiled application. A published WebApplication doesn't contain a web.release.config.
You should publish your project (rightclick on your WebApplication -> Publish) to your local filesystem and copy the files from there, or use another deployment method of your choice.
2 years ago I wrote an article about web.config transforms. It gives you a step-by-step tutorial for VS 2010 (The publish dialog changed in VS 2012): http://www.tomot.de/en-us/article/5/asp.net/how-to-use-web.config-transforms-to-replace-appsettings-and-connectionstrings
Inside your csproj file, you can add an action to execute before every build and perform the web.config transformations:
<Target Name="BeforeBuild">
<TransformXml Source="web.config" Transform="web.$(Configuration).config" Destination="web.config" />
</Target>
You can try the Slow Cheetah plugin:
http://visualstudiogallery.msdn.microsoft.com/69023d00-a4f9-4a34-a6cd-7e854ba318b5
This will let you see the transformations 'live' by giving you an extra context menu option. Right-click and choose Preview Transform to see the transformation without having to do a build. Its also really handy for implementing app.config transformations
I thought transformation is only done when you publish the site/app.
It is not done when building an application. The latter would constantly change the web.config under source control (which would be a real hassle)
If it's only connections strings that are not overwritten during web.config transformation, then this is what I did:
I cleared the "Use this connection string at runtime" check-box in the "Settings" section of "Publish Web" wizard. This setting was overwriting web.config transformation of the connection string.
It's pretty flexible, you should be able to make a few tweaks to apply custom transforms on build (and without having to publish)
We implemented this in our (Windows Service) project, applying transforms on build
You will need to modify your project file and add something similar to below
Here we're telling msbuild to apply transform after finish compiling, but only if condition is true (see https://learn.microsoft.com/en-us/visualstudio/msbuild/msbuild-conditions?view=vs-2017)
Notice we are using an build prop (self defined msbuild prop) "Env", e.g. msbuild ... /p:Env=Prod would result in App.Prod.config
<UsingTask TaskName="TransformXml" AssemblyFile="C:\Some\Path\Microsoft.Web.Publishing.Tasks.dll" />
<Target Name="AfterCompile" Condition="Exists('some condition')">
<!--Generate transformed app config in the intermediate directory-->
<TransformXml Source="App.config" Destination="$(IntermediateOutputPath)$(TargetFileName).config" Transform="App.$(Env).config" />
<!--Force build process to use the transformed configuration file from now on.-->
<ItemGroup>
<AppConfigWithTargetPath Remove="App.config" />
<AppConfigWithTargetPath Include="$(IntermediateOutputPath)$(TargetFileName).config">
<TargetPath>$(TargetFileName).config</TargetPath>
</AppConfigWithTargetPath>
</ItemGroup>
</Target>
On my local machine I'm developing using a certain db (sql server), however, when I deploy to the development environment we are running mysql. So everytime before deploying I have to change certain properties in the config file. Properties pertaining to the datasource:
<bean id="dataSource" destroy-method="close" class="org.apache.commons.dbcp.BasicDataSource">
<property name="driverClassName" value="com.mysql.jdbc.Driver" />
<property name="url" value="jdbc:mysql://127.0.0.1:3306/mydb" />
<property name="username" value="myuname" />
<property name="password" value="mypwd"/>
</bean>
Is there a way in spring mvc to have different config files for different environments? If so, how would I go about triggering the correct xml for the right environment.
spring mvc to have different config files for different environments?
we store database connection settings in a properties file in tomcat, each tomcat instalaltion then has its own specific db connection. Eg, a local dev box connects to the local DB server, the UAT server connects to UAT ... and so on.
then in app context we have :
<context:property-placeholder location="file:${catalina.home}/conf/database_UAT.properties"
ignore-unresolvable="true"/>
So where app gets deployed determines its DB connection.
i think having different config files for just this requirement is not an good idea.
you should externalize db configuration in properties file with two different set, one for dev and second for production. and then use spring EL in configuration file to decide which one to use.
Refer to spring EL documentation for more detail