Skip to main content

All Questions

Filter by
Sorted by
Tagged with
273 votes
13 answers
462k views

Read connection string from web.config

How can I read a connection string from a web.config file into a public class contained within a class library? I've tried: WebConfigurationManager ConfigurationManager But these classes are not ...
chamara's user avatar
  • 12.7k
101 votes
15 answers
733k views

Setting up connection string in ASP.NET to SQL SERVER

I'm trying to set up a connecting string in my web.config file (Visual Studio 2008/ASP.NET 3.5) to a local server (SQL server 2008). In my web.config, how and where do I place the connection string? ...
Ray's user avatar
  • 3,429
101 votes
3 answers
132k views

Escape quote in web.config connection string

I have a connection string in my web config: <add name="MyConString" connectionString="Server=dbsrv;User ID=myDbUser;Password=somepass"word" providerName="System.Data.SqlClient" /> As you see, ...
Sebastian P.R. Gingter's user avatar
45 votes
2 answers
46k views

How do I use Web.Config transform on my connection strings?

In my current project, I have some connection strings that are valid for local development machines: <configuration> <connectionStrings> <add name="ApplicationServices" ...
Mike Bailey's user avatar
  • 12.7k
37 votes
9 answers
140k views

Login failed for user 'NT AUTHORITY\NETWORK SERVICE'

I been strugling with this for 2 days now without comming any closer to solution. I have read 20-30 threads alteast and stil can not resolve this. Please help me out. I have disable anonymous ...
Dejan.S's user avatar
  • 19k
26 votes
4 answers
37k views

Testing - Connection string is missing

Visual studio created a unit test project for me based on a method (right-click add test). When I try to access the database, I get an exception. Ran this code to see what my connection was: ...
O.O's user avatar
  • 11.3k
26 votes
1 answer
48k views

How do you put environmental variables in web.config?

I am currently Following these tutorials, and I am wanting to call the clear text string from Azure's Application Settings for Web Apps. I am under the impression that environmental variables are used ...
Joseph Casey's user avatar
  • 1,293
25 votes
8 answers
19k views

Can I Add ConnectionStrings to the ConnectionStringCollection at Runtime?

Is there a way where I can add a connection string to the ConnectionStringCollection returned by the ConfigurationManager at runtime in an Asp.Net application? I have tried the following but am told ...
JamesEggers's user avatar
  • 12.9k
19 votes
2 answers
18k views

Encrypting the connection string in web.config file in C#

I have written the name of my database, username and password in my web.config file as connection string. I want to encrypt this data. How can I do it? <connectionStrings> <add name="...
Brigadier Jigar's user avatar
19 votes
4 answers
15k views

User Secrets in .NET 4.7 connectionstrings format

I have been digging for hours and keep coming up with information about .NET Core, yet hardly anything about .NET 4.7 full framework. I figured out how to add User Secrets to the main project of my ...
Connie DeCinko's user avatar
18 votes
4 answers
202k views

error: the details of the application error from being viewed remotely

I have 2 login pages: Login.aspx-for customer login and xlogin.aspx for admin login i just uploaded my project to the server and all application pages works great but when i log in the admin xlogin....
Olga91's user avatar
  • 207
18 votes
3 answers
10k views

Set the application ConnectionString in the Service Configuration instead of web.config in Azure

I have an application currently in Azure and whenever we push it into the Staging segment, we cannot truly test since the connection string is pointing to the prod database. Someone mentioned to me ...
Andy's user avatar
  • 183
18 votes
6 answers
102k views

How to add CommandTimeout to connection string in web.config

How to add CommandTimeout to connection string in web.config? I tried: <add name="ConnectionString" connectionString="Data Source=;Initial Catalog=;Persist Security Info=True;User ID=sa;Password=...
user avatar
16 votes
5 answers
13k views

Is there a need to secure connection string in web.config?

So I am using connection strings in my web.config using SQL authentication. Of course people say this could be a vulnerability as you are storing password in plaintext. However, from what I know, ...
Stellar Sword's user avatar
16 votes
1 answer
10k views

ELMAH Logging in SQL Server

I am having an ELMAH problem. I think it is the connection string but can't figure out why. It is emailing me errors no problem, just not logging them into sql. If the problem is permissions, how ...
Ethan Schofer's user avatar
14 votes
8 answers
40k views

error occurred while establishing a connection to SQL Server

If I have my connection string in the web.config like this (added line feeds for better readability): <add name="conn" connectionString="Data Source=(localdb)\v11.0; Initial Catalog=MyDB; ...
HMR's user avatar
  • 38.8k
14 votes
4 answers
2k views

How is everyone storing connectionstrings?

I was wondering if people could post their solution to the ongoing problem of local databases and different connectionstrings among many developers in one project within source control? More ...
Jonas Stawski's user avatar
13 votes
2 answers
13k views

Can't access the configuration manager from my solution

I have a three tier set-up. Someone suggested I should get the ConnectionString from the Web.Config file and I've got it set up like this: Now I'm trying to access the ConnectionString from my DAL ...
Sergio Tapia's user avatar
  • 40.8k
13 votes
5 answers
128k views

How to increase time in web.config for executing sql query

When I am running a query in web application, I'm getting a null value. Same query directly in SQL Management Studio returns results. I think that the problem is a timeout. How can I increase the ...
Jui Test's user avatar
  • 2,399
12 votes
3 answers
15k views

Get multiple connection strings from web.config

How to get all the connection strings's names from the web.config via code in C#? I tried this: System.Configuration.Configuration webConfig = System.Web.Configuration.WebConfigurationManager....
petko_stankoski's user avatar
12 votes
4 answers
44k views

Getting sql connection string from web.config file

I am learning to write into a database from a textbox with the click of a button. I have specified the connection string to my NorthWind database in my web.config file. However I am not able to access ...
A_AR's user avatar
  • 508
11 votes
1 answer
6k views

Separate ConnectionStrings and mailSettings from web.config? Possible?

Is it possible to separate ConnectionStrings and mailSettings from web.config? Devel environment has different IP addresses for connectionstrings and smtp mails because of development and testing. We ...
feronovak's user avatar
  • 2,687
10 votes
1 answer
2k views

In C# , how can I read a connection string stored in my web.config file connection string?

In C# class library, how can I read a connection string stored in my web.config file connection string tag? As in: <connectionStrings> <add name="CLessConStringLocal" connectionString="...
Shyju's user avatar
  • 217k
10 votes
3 answers
17k views

ASP.NET: How to create a connection from a web.config ConnectionString?

How do you construct a DbConnection based on a provider name? Sample provider names System.Data.SqlClient System.Data.OleDb System.Data.Odbc FirebirdSql.Data.FirebirdClient i have connection ...
Ian Boyd's user avatar
  • 253k
10 votes
4 answers
53k views

How to connect to Oracle DB from .NET?

When I open SQL Command Line, I write CONNECT username/password@[//]host[:port][/service_name] and it connects me to the database just fine. However, I'm unable to connect from a .NET project using a ...
Mathieu Roy's user avatar
10 votes
2 answers
10k views

Retrieve and use Windows Azure's connection strings?

I've configured connection strings in Azure management portal Configure->Connection Strings (linked resources): What are these connection strings useful for? I tried deleting the conn. strings from ...
Shimmy Weitzhandler's user avatar
10 votes
1 answer
20k views

How to read a connectionstring in .net 4.5

How do I read a value from the web.config file for a connectionstring in the 4.5 .net framework? I'm using system.configuration which I have a reference to and a using statement, but the only thing ...
sagesky36's user avatar
  • 4,642
10 votes
2 answers
49k views

Calling a stored procedure with asp.net

If I have a connection string defined in my web.config file, how do I create a connection to the SQL db from C# code (sorry forgot to specify) and then call a stored procedure. I would then like to ...
onit's user avatar
  • 6,356
10 votes
3 answers
5k views

Single Connection String with Multiple Entity Framework Models?

At work we currently have a very large web application with a connection to a massive database. We have been using Entity Framework for a while now and to make things easier we divided the database ...
Lukasz's user avatar
  • 8,810
9 votes
3 answers
23k views

C# connection string in web.config file

In my code behind page, how do I access the connection string which is stored in my web.config file?
flavour404's user avatar
  • 6,262
9 votes
2 answers
13k views

EntityFramework can't see ConnectionString in the App.config

I am studying Code First EntityFramework together with ASP.Net MVC 3. At first my trivial EFDbContext class was placed in the WebUI mvc project in a Concrete folder. public class EFDbContext : ...
horgh's user avatar
  • 18.4k
9 votes
2 answers
13k views

Modify web.config with powershell

I need to try to update a web.config file to change the IP address only of the web.config I have included the section of code Im looking at for powershell to script the change. <connectionStrings&...
Sc-python-leaner's user avatar
8 votes
3 answers
35k views

Creating a string in a web.config and use it in a web.api

I am new in the web development world and I would like to create a variable in the web.config file so that I can use it in the .NET portion of the web.api I found the following tutorials on how to do ...
user1415780's user avatar
  • 1,153
8 votes
3 answers
4k views

.NET 4: How to configure EDMX file in other assembly in Web.Config

I have a problem with configuring an EDMX file that lives in an other assembly than by web project. My project looks somewhat like this: Project 1 --> Database.edmx --> App.Config Project 2 --&...
Erwin's user avatar
  • 1,492
7 votes
2 answers
2k views

Can I reuse an Existing Connection String in my SQL Session State Config?

I'm using SQL Session State in my app, however given that we have several connection strings already, it would be easier to maintain the config if all the connection strings were held, well, in <...
StuartLC's user avatar
  • 106k
7 votes
2 answers
4k views

Can i execute Azure webjobs without AzureWebJobsStorage connectionstring?

When i create new Azure webjob project i could see the connectionstring section in app.config section as below: <connectionStrings> <!-- The format of the connection string is "...
ManirajSS's user avatar
  • 2,365
6 votes
2 answers
13k views

Determine correct connectionString for web publishing for ASP.NET-MVC application

During development of ASP.NET-MVC application on local machine I used this connectionStringwith no problems whatsoever: <connectionStrings> <add name="DefaultConnection" connectionString=...
Yoda's user avatar
  • 17.9k
6 votes
1 answer
2k views

share connectionstrings with multiple projects in same solution

I have multiple projects in the same solution. I would like them to share the same connectionStrings so that I don't have to change the this in multiple places. In my web configs I have <...
D Rod's user avatar
  • 191
6 votes
2 answers
7k views

LinqToSql dbml dynamically switch connectionstring

We have two databases, DEV and STAGING. They are for the most part identical. I have an app settings tag in the Web.Config call it "mode", and two connectionstring entries. If mode=DEV I want to use ...
Hcabnettek's user avatar
  • 12.9k
6 votes
1 answer
2k views

ELMAH and SQL Server 2008 R2?

I try to run ELMAH with my ASP.NET MVC 2 project but have some problem to get it to work with my SQL Server 2008 R2 database. This is what I have done. Run the dbscript in my database, accidentally ...
Banshee's user avatar
  • 15.7k
6 votes
1 answer
2k views

web.config encryption for web sites

i already found information about how to encrypt the web.config with a custom provider and certificate for web roles in order to secure connection strings and other settings. Is this also possible ...
user2500771's user avatar
6 votes
3 answers
2k views

ASP.NET MVC 5 Azure Website fails to connect to SQL Azure DB on some views due to role based [Authorize] attribute

We have an ASP.NET MVC 5 website, which works fine when we run it locally with Visual Studio. When run locally the website is connected to two SQL Express databases (the AspNetUsers & our Content ...
Smile5.09's user avatar
  • 169
6 votes
3 answers
3k views

ASP.Net configuration file -> Connection strings for multiple developers and deployment servers

I have a team of three developers, two of whom use a standard local test database, one of whom uses his own database and there is also a server environment with a production database and a testing ...
Nathan Ridley's user avatar
5 votes
4 answers
5k views

How to access a connection string from within a library

I have a web project (mvc) and data access layer in a separated class library project. I need to access to a connection string in app.config which sits in that library project. ConfigurationManager....
iLemming's user avatar
  • 35.6k
5 votes
2 answers
6k views

Web.config in virtual directory is not overriding parent website's Web.config

I've got a website which has a virtual directory that also includes a website, and when I try to launch a page from the virtual directory, I receive an IIS 7.5 error that the name (from the connection ...
u84six's user avatar
  • 4,833
5 votes
2 answers
1k views

ConnectionString configSource not found when deployed to Azure

I am securing my MVC5 project, by moving the connection strings out of web.config into an external file, and not checking this into source control, nor adding it to the project. My web.config looks ...
Joel Gallagher's user avatar
5 votes
2 answers
10k views

connection string for remote database server

I have 2 servers setup at the moment. One is a web server running Win Server 08 and the other is a database server running SQL Server 08 on Win Server 08. Currently I have my site setup so that it ...
Richard Reddy's user avatar
5 votes
3 answers
3k views

ASP.NET connection string deployment best practice

I've collected a (hopefully useful) summary of the ways I've researched to accomplish the subject of this post, as well as the problems I have with them. Please tell me if you've found other ways you ...
Shannon's user avatar
  • 241
4 votes
4 answers
23k views

Configure my connection string in the Azure application setting and configure it in my web.config as an environment variable

I have a Web App in Azure and I configured the connectionStrgin in its application setting, but I do not know how I can set this configuration as an environment variable in the application web.config (...
Nicolas Herrera's user avatar
4 votes
3 answers
5k views

double quotes inside double quotes

i am writing the following connection string into web.config but it giving me error.what is the correct way to write it? <add name="stargaze_stargazeConnectionString1" connectionString="Data ...
gofor.net's user avatar
  • 4,268

1
2 3 4 5