Solved

UPLOAD file path in webconfig

Posted on 2011-03-11
4
712 Views
Last Modified: 2012-05-11
I am building a project for a client.  I need to be able to upload files to a directory ... I was thinking about putting the path into the webconfig so that the client could just change the name latter to what works for them when the get the code...

Could somebody tell me how that would be done OR if there would be a better way to do that?
0
Comment
Question by:vbnetcoder
  • 2
4 Comments
 
LVL 5

Accepted Solution

by:
mayankagarwal earned 500 total points
ID: 35114589
For global variable you can use the <app key="varName" value="varValue"> tag in web.config file in your asp.net project. There are some other ways also to declare a global variable. You can also use application or session objects to maintain your data between multiple pages. This is the treditional way to make a variable global, but in asp.net we can also use the web.config setting for global declaration. The important part of using the global var in web.config file is that you can change the values on the fly. Means you dont need to complie your application.

for app setting the syntax is

<appSettings>
<add key="varName" value="varValue" />
<appSettings>

to access the variable

string strVar = System.Configuration.ConfigurationSettings.AppSettings["varName"].

For application variables

'To store a variable:
Application.Lock()
Application("MyVar")="whatever"
Application.Unlock()

'to retrieve the variable:
Dim s as String = Application("MyVar").ToString()
0
 

Author Comment

by:vbnetcoder
ID: 35115539
Is their any way to put path into session automatically when the application starts so that I can just grab it so I can just grab it  from the session when I need it in the application?
0
 
LVL 18

Expert Comment

by:Gary Davis
ID: 35115948
During the startup of the application (Global.asax.cs), I have occasionally iterated through all appSettings and store them in the Application object for easy access. Also, you could create a strongly typed class to hold them too (not quite as generic as using Application).

Gary Davis
0
 

Author Closing Comment

by:vbnetcoder
ID: 35160989
ty
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

I have developed many web applications with asp & asp.net and to add and use a dropdownlist was always a very simple task, but with the new asp.net, setting the value is a bit tricky and its not similar to the old traditional method. So in this a…
One of the pain points with developing AJAX, JavaScript, JQuery, and other client-side behaviors is that JavaScript doesn’t allow for cross domain request for pulling content. For example, JavaScript code on www.johnchapman.name could not pull conte…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, just open a new email message. In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now