Store / Access - Application Wide Variables Or Globals In Asp.net

Feb 8, 2010

What is the recommended or usual way an ASP.net web application(in C# language) can store/access values that are needed accross the various pages in a website. For example a basic company website might need the company's name and other related information available to multiple pages. Where do I declare these variables/values and how do I access them. Coming from c++ application programming I would usually store such data in a Singleton class object.

View 5 Replies


Similar Messages:

Access "Application" Object In MVC To Store Application Wide Variables?

Aug 7, 2010

How do I store a variable or object application wide in ASP.net MVC. In regular ASP, you had the Application object, and in ASP.net too apparently.

View 1 Replies

Where To Store And Set User Site Wide Data In MVC

Feb 16, 2010

I have an application in which a user can choose from different (learning)groups. User has only access to registered groups. When the user enters the site, he can choose (in a dropdown) which group he wants to see, so the complete site filters content related to that group. So every controller needs to access this global "group" object.What is the best way to do this in ASP.NET MVC? I've thought about a BaseController or ActionFilters. Is there any other best practice?I've build a WebForms application and there I used a BasePage so that any other page has access to the group.

View 2 Replies

C# - How To Enable Access To Application Variables Inside A Web Service

Dec 15, 2010

I know I can allow the web service access to Session variables by adding (EnableSession=true). Is there a way to allow it access to global Application variables?

I have several resource intensive variables that are loaded in the Global.asax and I need access to there in the webservice.

View 1 Replies

Web Forms :: Method For Specifying Application Wide Settings?

Apr 5, 2010

I want a separate config file (not app.config) that stores style for various controls in my web application. For example i want to specify the CSS file that modifies all instances of GridView in the website. what is best practice?

View 2 Replies

Web Forms :: Using Application Wide Master Pages?

Jan 12, 2011

i added this entry in my web.config file

pages
masterPageFile="~/default.master"

so that all my content pages (.aspx) in my application could use default.master as their master page,

i read we do this so that we don't have to mention the MasterPageFile="~/default.master" everytime in all the .aspx content pages, but , my query is whenever i add a new .aspx page in my website from VS 2010, it dosen't automatically add MasterPageFile="~/default.master" to the Page header, am i missing something.

View 2 Replies

C# - How To Store Accounts Access Information's Inside Application

Mar 6, 2011

I need to keep access settings to different web pages inside of my asp.net application. These setting are logins and passwords for those pages. Is it safe enough to keep them in web.config in section?

View 1 Replies

C# - Where To Store The Global Settings To Allow The Application To Access Them Frequently

Mar 7, 2011

I have some global settings in my application that is going to be handled by the administrator and I store them in the database.

Settings like: board on/off, max items/page on different UserControls, language, hide/show modules.

What technique should I follow to read the values in the database and display the page or the application according to it .. Of course I could do it the easy way and fetch the required settings for each page in the Page_Load event handler but I think that will be a lot of database connection!

View 1 Replies

Working With Static Variables / Store The User Specific Information In Static Variables?

Mar 5, 2011

whats the exact use of static variables in overall programming in .net and for asp.net...

Recently i went for the interview where interviewer asked me 2 question which i was not sure for the same..

whats the use of session object, i said sessions are the server side object, they are used when you want to store user specific data at server side, then he asked what if i want to use static variables for the same, i was mum, can anyone tell me how asp.net will behave if i store the user specific information in static variables.If i use cookies which are the best option to store the data at client side (not sensitive one), but what if user has disabled cookies on his machine, will my application would crash.

View 3 Replies

C# - Where To Store Sensitive Variables

Apr 4, 2011

This is my first time working on a secure website. It's for a pet project I have.

For security purposes, where is it best to store information like SQL connection strings, database encryption keys, etc? Is it better to use web.config, store them in a class that accesses a database (like dataBaseHelper.cs or something), or somewhere else?

I intend to obtain an SSL cert as well. When communicating with the database, should I always use the secure connection?

View 2 Replies

Web Forms :: Store Large Data Using DataTables In Session Variables?

Apr 30, 2013

if i want to get multiple values from database and pass this dataset to another page can we use session to store the dataset values..i knw we can..but some one says that its not a gud approach..this will cause server process down..is it true?if it so then wat are all the other ways to do that?

View 1 Replies

Access :: How To Upload Image In Visual Basic And Store In MS Access Database

Jan 8, 2011

I want a piece of code for asp.net 3.5 using visual basic. and i am using MS access database.

I have two three text boxes and 2 image upload controls and a submit button.

I want a piece of code in which a user can upload images and store it in our database . i want an asp.net visual basic working code. also i need query behind the submit button.

View 4 Replies

Access :: Store The Ajax HTML Editor Text In An MS Access Database?

Jan 2, 2010

I am using ajax html editor to write a text. I can view it without having problem but I am incapeble of storing it in a Ms Access database. which type do I need to use for this? I tried memo and OleObject type and both didn't work. I used the blow code for that.

View 6 Replies

Access :: Attempting To Store A Date Into Access Db?

Mar 8, 2010

im trying to store a date in an Access database i set up the column in the db to be type Date/Time and have the following code to attempt to insert into itDim objTest As New OleDb.OleDbCommand("INSTERT INTO orderForm (OrderDate) VALUES (@OrderDate)", objConn)
objTest.Parameters.Add("
OrderDate", DateTime.Now)
Dim objTestExec As OleDb.OleDbDataReader = objTest.ExecuteReader()

however it yields the following error when i execute invalid SQL statement; expected 'DELETE', 'INSERT', 'PROCEDURE', 'SELECT', or 'UPDATE'.ive also had a variety of other errors with my efforts so im not really sure what the deal is here

View 11 Replies

How To Access Variables In Postback

Mar 11, 2011

how do I access variables in a simple asp.net postback using either POST or GET?

View 2 Replies

C# - How To Store/construct Complete Queries, As Using Simple SQL And Variables And "+"

Feb 12, 2011

I am not aware of the correct term used for the following procedure in LINQ but i hope there is a way.

SIMPLE SQL QUERY

select this from table where alpha would be this and that

To construct this sort of thing, I would (IS A REQUIREMENT) normally use variables like this:

[code]....

a thousand tables, i would have to write queries from all tables using there instance, to perform the exactly SAME TYPE select function!!!

what is the way around this

provide some links, source code examples, resources, books name.

View 1 Replies

How To Use Application Variables

Jan 26, 2011

I cant figure out how to use the Application["myvar"] variable to store data for the application in asp.net 4.0 web app using c#. It say Application is not a known object and I can't for the life of me figure what to do a "using" on to expose it. I am in a static class at the time I cant use it. It seems to work in other units?

View 3 Replies

How To Access Variables Defined In Masterpage.master.vb

Feb 1, 2010

I have a collection of cookies filled with Browserhawk information in masterpage.master.vb such as;

Dim useCSS as boolean = 0
Response.Cookies("Stylesheets").Value = brHawk.Stylesheets
if Response.Cookies("Stylesheets") = True then useCSS = 1
if Stylesheets is True I set useCSS to 1, if false I set useCSS to 0

I need to access these in the section of the masterpage.master such as;

if useCSS = true
Then load stylesheet
else
Dont load stylesheet

I'm having problems finding the right syntax to get this working.

View 2 Replies

WCF / ASMX :: Access Session Variables Through A Web Service?

Mar 29, 2011

In my ASP.net website we are going to use Silverlight to display some interactive diagrams. The users can add, edit and delete various diagrams on the silverlight front end. Silverlight will call Web Service methods to save the changes into the database. Besides the data being passed by silverlight to web service call, we also need to pass some data from the session (like logged on user id etc.) to the web service call.

My question is that how silverlight can access session data? I am trying to pass session information via a webservice method call over to Silverlight but, the session variables inside the web service methods are returning null value.

The Web Service is running under the same web root where the ASP.net website using Silverlight is also hosted. I have made EnableSession = True for web properties.

View 1 Replies

Application Variables Work The Same In Both ASP And ASP.NET

May 16, 2010

This question actually refers to a classic ASP page I'm working on, but I'm assuming that app variables work the same in both ASP and ASP.NET Let's say we have a bunch of websites, owned by different people. The sites are all different, but the common theme is they are car enthusiast websites. Each of these websites has their own unique index page (of course), but also "common" pages, which are pages shared by all the websites.

One of the common pages, checks for the value of an application variable, which may or may not exist. For example, lets call this page luxurycars.asp, which is a simple page that shows the top 10 luxury cars of this year. This common luxury car page will pull and use the app variable like so:

[CODE]
Dim SiteOwner
SiteOwner = Application("OwnerName")
Response.Write("This site is managed by " & SiteOwner)
[/CODE]

This app variable is set uniquely in each clients index.asp page like so:

[CODE]
Application("OwnerName") = "John Doe"
[/CODE]

Will this work? I just started learning classic ASP (for my job), and I'm reading that application variables are universal and only one copy of the variable will exist. So does this mean if John Doe sets Application("OwnerName") to "John Doe" in HIS index.asp page, will everyone that visits the common luxury car page see John Doe's name? Regardless of whether they got to that page via John Doe's page or someone elses? And if so would using a Session variable instead solve this problem? Sorry if this sounds confusing, let me know if I need to re-word it or give more detail...

View 2 Replies

Modifying Application Variables In (MVC)?

Mar 15, 2011

I store a large structure holding my application's reference data in a variable I access through HttpContext.Application. Every once in a while this data needs to change. When I update it in place, is there a danger that incoming requests will see the data in an inconsistent state? Is there a need (and a way) to lock some or all of this structure? Finally, are there other approaches to this problem other than querying the database every time you need this (mostly static) data?

View 3 Replies

Access Post And Get Variables In A Server Control Class?

Dec 15, 2010

I need to access post and get variables inside a server control class, there is no access to Request object in server control class...

View 1 Replies

Access Public Page Variables From ListView.EmptyDataTemplate?

Jun 13, 2010

is it possible to access public page variables from ListView.EmptyDataTemplate ?

View 1 Replies

Web Forms :: Static Variables Throughout Application

Oct 6, 2010

i am developing a website in asp.net i have created a class "Utility" in App_Code Folder this class contains a static object of another class(LoginInfo) as described below:

[Code]....

This LoginInfo Class is my business object which only contains 2 properties UserID and UserName
Now what i am doing on my login page, after user authentication i am setting these properties with current logged in UserId and UserName

[Code]....

I am using this CurrentUser object on my webpage to get userid and username. It works fine, but after few minutes my CurrentUser.UserID and CurrentUser.UserName is set to blank string. I am not able to figure out what is the problem. may be due to asp.net recycles.

View 3 Replies

C# - Use Session Variables In Windows Application Using VC#?

Feb 24, 2010

im new to asp.net. . . im doing my final year project.How to use session variables in application using VC# and I also need to check with data base?

View 2 Replies







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