Refer To Web.config Key Names In Code

Jul 1, 2010

When your web.config or app.config file has an appsettings entry, what is the best way to refer to its key in your code file? Developers I have worked with have differing opinions on this. Some say to hard code the string and others suggest that there should be a file containing string constants and in your code, you use the constant as the appsettings key. I would be interested in hearing other opinions on this. What do you do? Why is it the best?

View 4 Replies


Similar Messages:

DataSource Controls :: Refer To Datatable Columns With Database Column Names?

May 28, 2010

[Code]....

Refer to datatable columns with database column names?

View 3 Replies

Security :: How To Store User Names And Passwords In Web.config

Mar 8, 2010

I'm trying to find out how i store user names and passwords in the web.config file. I have tried looking for documentation on this but haven't found any so far.

I see in the class library it says that the Authenticate method of the FormsAuthentication class is for use in authenticating credentials against those stored in the config file, but i don't know how to store them there to begin with. I want to store two username:password pairs in the web.config file preferably encrypted.

one of these username:password pairs i want to be hard coded. The other i want to be able to be reset with a password reset form which I will code later. I guess there maybe a method for creating a sername:password entry in the web.config which could be used with my password reset form if such a method exists. But I need to know how to hand code the username:password entries into the web.config file to begin with and to beable to create the hard coded pair.

code I need to add to my web.config file i need to add and in what section?

also can you point me in the direction of a method used for creating username:password entries in web.config

View 6 Replies

DataSource Controls :: Storing Required Field Names In Web.config?

Feb 2, 2010

I am writing an app that has a bit of process flow to it. On the save of a record, I need to check some fields to make sure they are not null. If they are not null, I will update a 'SectionComplete' field to true.

The thing is, I would like to store my fields in the web.config. So, I would like to have a string in the appsettings section that has a list of field names that are required. Then in my method, I would call these fields out and check each one for the specific record id, and then update the database.

I would like to do this in the web.config so we could add/remove columns without having to redeploy.

For example: my required fields are name, id, and phone. For section one to be labeled complete, all of these fields would need to be not null.

web.config would have this entry:

<add key="Stage1Fields" value="name, id, phone"/>

View 4 Replies

Security :: Saving Stored Procedure Names And Connection Strings In Config Files

Aug 3, 2010

I have heard that saving connection strings and stored procedure names in web.config file of our application is not safe. It is a good practice to store the connection string in a config file rather than as a hard coded string in our code and if we need to change it,then it makes our job easier. how to protect our code in web.config?

View 4 Replies

How To Setup For Sharing Code Across Multiple Domain Names

Mar 8, 2010

I have built a website and now the customer wants to split it between three different domains. What is the best way to do this? This is what I have so far.

c:/website1/ points to www.website1.com
c:/website1/vd1/ points to www.website2.com
c:/website1/vd2/ points to www.website3.com

The webhost I'm working with has done it the following way, but now I'm getting a bunch of errors that seems like it's not seeing the App_code folder. Do I need to make a lot of changes? How does this affect the location references?

View 2 Replies

DataSource Controls :: Take Names From The Table And Do Another Select Based On That List Of Names?

Jun 1, 2010

I have been working with this database for some time. Here is the situation...

I inherited a MS SQL database that has hundreds of tables with similar data. For instance:

FordTampa_customer is a table,

ChevyAtlanta_customer is a table, etc....

All of the columns are the same...just different tables with their own ID field. All I have done...Inside of another database id is created a table called 'Customer' and added an 'Dealer ID' column along with the rest of the other columns in the other tables...

So the combination of the 'Dealer ID' and the 'ID' field are unique.....I know...its not the best way to do things...but I cannot change the old data structure because I cannot have access to it. I am give back-ups on a weekly basis, so this is all I have to work with.

All right, on to the real point of my post...

Currently, I have an application that I use to select all of the data from the 'Ford_customers','Chevy_customers',etc... and inserts them into my new main 'Customer' table. I do this by selecting the table names, bind it to an arraylist, loop through the list and execute an insert statement.

I do this in VB.NET, but I would prefer to do it in a Stored procedure of some kind....I just am not sure how to accomplish it. I use this syntax to get my list of tables:

[Code]....

I am not sure how to take those names from the table and do another select based on that list of names.

View 1 Replies

Web Forms :: How To "parameterize" Dropdownlist Names To Create Several Copies Of The Aspx Code

Feb 28, 2010

We have a row of aspx code that lists employees and hours worked and total hours. The text is quite simple and uses ajax to update the entries when the user selects a control for employees or enters hours worked on a particular project.

Currently, we have "hard coded" these lines of code. It works fine, but is quite tedious to change when requested. The difference between row1 and row2 is minimal. Just some control name differences such as

dlEmployees1 and ddlNrOfHoursWorkedRow1Col1, ddlNrOfHoursWorkedRow1Col2, ddlNrOfHoursWorkedRow1Col3, ..., lblTotalHoursRow1

on one row, and then

dlEmployees2 and ddlNrOfHoursWorkedRow2Col1, ddlNrOfHoursWorkedRow2Col2, ddlNrOfHoursWorkedRow2Col3, ..., lblTotalHoursRow2

on the next row. Etc.

Our first goal is to re-write one of these lines into something like an array that can be similar to dlEmployees[j], ddlNrOfHoursWorkedRow[j]Col1 and lblTotalHoursRow[j]

so we can add and reference the different drop down boxes in the c# code.Below is the actual code for 2 lines (sorry for the long post).

==================== code follows for 2 sample lines =====================

<!-- Drop Down Lists for Employee Names (1st Employee Row) (Row Nr 7 of Table) -->
[code]....

View 3 Replies

To Put All Sql In The Web.config Instead Of Code Behind?

Sep 13, 2010

I'm making the switch from vb.net to C#. And with that, I want to move away from using sql datasources in the aspx page, and put the code to execute my sql statements "where it should be". Only thing is, I don't know where exactly that is. Basically, there are a three or four stored procedures that a page of this small website may need execute per page.Instead of putting all this in the code behind of the first page, and then copy/paste similar in other pages, I'd like to put it all together in one spot and then have each page "call" as needed. Problem is, I just don't know where/how this should be to do this the proper way. I'm trying to learn a better way of coding this...

protected void getSectionContent()
{
SqlConnection conn = default(SqlConnection);
SqlCommand comm = default(SqlCommand);[code]....

View 3 Replies

Modifying Root Web.config In Code?

Jan 30, 2011

I would like to store some meta-information about a given site instance that can (a) be managed by that site instance and (b) persist clobbering of Web.config file.The site will run in multiple environments (dev,testing,staging and production) and each environment can have different values for this metadata.
Note: All environments are running IIS 7.0+

The Root Web.config seems very appealing, as it is certainly outside of the website. Therefore, both files and databases can be changed while maintaining the metadata. I have seen how to modify the appSettings of the Web.config stored in the website, but is it possible to similarly modify the appSettings in the Root Web.config (Specifically within the proper directive)?

View 2 Replies

Read Value Of Timeout From Web.config To C# Code?

Mar 8, 2011

<sessionState timeout="1440"></sessionState>

how can i read value of timeout from web.config to c# code

View 2 Replies

Web Forms :: Refer Control Id From A ContentPlaceHolder?

Jun 2, 2010

How do i refer a control id from a different ContentPlaceHolder by using inline code?

I have filterParameters which refer a control (txtSearch). Since it was place in different contentplaceholder (ContentPlaceHolder2) , its id could not be find by it name "txtSearch", is there any inline code syntax can help me?

for example,

[Code]....

View 3 Replies

Web Forms :: How To Refer To The External Themes

Jun 4, 2010

We have multiple themes and based on the employee login we need to set the themes. And my themes folder including images, style sheets etc resides outside my application ie inside my master page project.When i refer the theme to it i am receiving an error stating its not valid theme.Cant we refer the external themes and set it page.theme?Any idea on this?

View 5 Replies

Refer Shared Function In Its Own Class?

Mar 2, 2010

how to refer shared function in a class , this function itself inside same class

public class cls1

Public Shared Function getDBDate(ByVal pDate As Date) As String
Return Format(pDate, "yyyy-MM-dd")
End Function

Private Function GetDb_Format(ByVal pDateString) As String
Dim d As Date = Me.ParseDate(pDateString)
Return clsDate.getDBDate(d)

End Function

End Class

can i have any other way to use getDbDate function

View 2 Replies

VS 2008 GridView - How To Refer To The Row That Is Updating

Mar 13, 2010

I'm facing the following issue:

I have a gridview that allows updating. I only want to show the relevant fields to the user. As a result I hide the ID field of the records. But I need this value as a parameter for my update command. Apparently the value is always passed as 0 when the field is set invisible. When the field is set visible, the right value is passed.

I know it is possible to refer to a selected row and its controls, to get their values, even for invisible fields. This is what I want to do when the row is updating, in order to get the ID value of the label control which holds the ID value. How do I refer to the row that is updating? I experienced that the row is not considered 'selected', so the SelectedRow property of the gridview does not do the trick.

View 4 Replies

Link To Refer Which Gives Precise Information?

Aug 19, 2010

i would like to know about AutoEventWireup="false".

give me a brief description or a link to refer which gives precise information.

View 3 Replies

Mulitple Websites Using The Same Code But Different Web.config Files?

Oct 18, 2010

I have mulitple websites using the same code but different web.config files. Is there a way where I can achieve not having multiple copies of the same code? so its easy to mantain?

View 1 Replies

VS 2008 - Accessing Setting From Web.config From Vb Code?

Apr 30, 2010

I want to use the setting stored in the web.config file in my vb code, but don't know how to reference them.

More specifically I want to access the Host name, username and password in the smtp settings to send an email. My web.config is

[code].....

View 11 Replies

C# - Two Connection Strings In Web.Config And Switch Between Them In Code Behind?

Nov 19, 2010

How Can We Have two Connection Strings In Web.Config And Switch Betweeen Them In Code Behind? when i add two connention strings in web.config so an error appears that tells us u cann't add two connection strings in web.config. i want the upper job because i have 2 databases and i want transfer data from another to the other one.

View 4 Replies

C# - Dynamically Register An HttpHandler In Code (not In Web.config)

Mar 23, 2010

Is there a way I can dynamically register an IHttpHandler in C# code, instead of having to manually add it to the system.web/httpHandlers section in the web.config.

This may sound crazy, but I have good reason for doing this. I'm building a WidgetLibrary that a website owner can use just by dropping a .dll file into their bin directory, and want to support this with minimal configuration to the web.config.

View 2 Replies

C# - Use Connectionstring From Web.config In Source Code File?

Mar 15, 2011

I know this might be a very basic question, but maybe thats why im having problems finding the answer. Right now I'm creating database connections in my source files by doing something like this:

SqlConnection con = new SqlConnection("Data Source=...Password=...);
SqlCommand cmd = new SqlCommand(String.Format("SELECT * FROM Table;"), con);
con.Open();
SqlDataReader reader = cmd.ExecuteReader();

But this means that if I choose to change databases it will be a major pain in the ass. Do you guys know how to use the connection string from a web.config file instead?

View 5 Replies

AJAX :: Adding The Same Dll Of Controltool Kit And The Same Code In Web.config?

Feb 6, 2010

I am using ajax controls in my website. In my previous website I used these controls and they worked well but when I started a new website and I used these validators, fiter textboxes they donot work. I am adding the same dll of ajaxcontroltool kit and the same code in web.config. Don't know what is the issue.Please can anyone let me know why this happens or am I doing any mistake.

View 5 Replies

Web Forms :: Refer To Label In Aspx From Ascx?

Oct 17, 2010

refer to label in aspx from ascx? .......

View 1 Replies

Web Forms :: How To Refer A DDL From A Previous Aspx Page

Apr 15, 2010

i have couple of aspx pages, both have drop down lists (DDLs) in them. A user first goes to Page1.aspx and choose a value from the DDL-1 and click on Submit button. He is then taken to the Page2.aspx which again has a DDL-2. What I want is to populate the
DDL-2 based on what was chosen in DDL-1. I am not able to figure out how to access something that was chosen on a previous page. I believe I need to create a reference to the previous page? Please help me out with this.

View 7 Replies

How To Check For User Login And Refer URL For Security

Sep 17, 2010

I have two server one server runs (windows 2003 server Moodle opensource - PHP url : [URL] and another server contains Course Matterial video(url :[URL]. so user success full login i have transfer to another server. how can i know it is successful login and it is request comes from xxx.yyy.zzz.aaa ip.

i want write code in C# (asp.net)

View 1 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved