Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Read Variable from Web.Config

How can I add and read the value from web.config file?

like image 559
Amira Elsayed Ismail Avatar asked Oct 04 '10 11:10

Amira Elsayed Ismail


People also ask

How to read connection string from web config file?

Read Connection string from web-config using C# Now, one of the most frequently asked or used code in C# is reading connection string from WebConfig file to use it in C# code, for saving data in database or reading data from database. So, suppose your connection string webconfig file looks like this

How to read web config values from JavaScript?

One way for doing this is to add the java script in the .aspx page. <appSettings> <add key="test" value="textBox"/> </appSettings> We are globally setting this variable so we can access this variable inside our static js file my js file home.js So we can read web config values from javascript by this way.

Is there any way to edit web config using Java Script?

Is there any way to edit web.config <pages theme="Theme3" /> using java script.If so will u please give me a sample code. There is no way to edit a Web.config file using JavaScript as the file is on the server and JavaScript runs on the client.

What is web config configuration in ASP NET Core?

In this article, we shall see how to Read Web.Config Configuration .NET Core-based applications like ASP.NET Core or MVC or non-host applications. Web.Config is actually a useful and most widely used format used for providing configurations details required for an application to be able to run properly.


1 Answers

Given the following web.config:

<appSettings>      <add key="ClientId" value="127605460617602"/>      <add key="RedirectUrl" value="http://localhost:49548/Redirect.aspx"/> </appSettings> 

Example usage:

using System.Configuration;  string clientId = ConfigurationManager.AppSettings["ClientId"]; string redirectUrl = ConfigurationManager.AppSettings["RedirectUrl"]; 
like image 50
PrateekSaluja Avatar answered Sep 22 '22 15:09

PrateekSaluja