.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

Accessing static variable in global.ashx file

Posted By:      Posted Date: September 28, 2010    Points: 0   Category :ASP.Net

Hi All ,

I want to access the static variable in my global.ashx file  I am using classname.variable name for accessing the variable but the variable name dose not appear.Can someone tell me how to access static varialbe in *.ashx file.

View Complete Post

More Related Resource Links

Application variable or static class for global string?


I need to keep a global variable throughout the whole time the user is at my site, but do I use Application or a static class? The string variable should store a region name and my site makes a few changes depending on which region that has been set.

I read that Application was mainly for classic ASP, but I also read that a static class cannot be instantiated at runtime (e.g. when the user has logged in).

So, have I got something wrong here and which solution do I use?



Problem in accessing resource file dynamically.


Steps I have followed are
1.I have created myres.en-GB.resx file at C:.
2.then created locale specific myres.en-GB.resources using resgen at c: only,
resgen c:\myres.en-GB.resx
3.Linked the Resource File to Assembly using AL.exe which is giving me assembly at c: only.
Al /t:lib /embed:myres.en-GB.resources /out:ClassLibrary1.dll
4.I have created one web application using vs 2008 & then build it.
5.Then placed both resource file & dll in web applications Bin\en-GB folder.
6.Anf finally written code at page load like
 CultureInfo info = new CultureInfo("en-GB");
            Thread.CurrentThread.CurrentCulture = info;
            Assembly asd = Assembly.Load("ClassLibrary1");
            ResourceManager res = new ResourceManager("myres.en-GB", asd.GetSatelliteAssembly(info));
            string sdf = res.GetString("Lab1");

but after running application I m getting following error
MissingManifestResourceException", "Could not find any resources appropriate for the specified culture or the neutral culture. Make sure "Cla

Accessing Username, password, roles in xml file


Currently I am storing my username and password (passwordFormat="SHA1") credientails in my web.config.  I would like to figure out how to access them in an xml file that I have stored in my App_Data directory rather than the web.config file because I do not want my application restarting everytime I manually add a user (small list of 5 authorized users for the CMS section).

Here is what my web.config section looks like:


<authentication mode="Forms">
      <forms name=".Administration"

File Upload to an .ashx Script.


Hoping that someone can help me with this. I've been tearing my hair out for days looking for sources and coming up with nothing.

Basically, the scenario is this: I'm working on a project whereby an iPhone will make an HTTP-POST call to an .ashx file on my site. The POST will consist of some fields and a file.

I'm having difficulty - read that as no luck what-so-ever - in finding the form fields or the file when I look at the HTTPContext object in the debug mode of Visual Studio. And if I look at HTTPContext.Request.Files.Count (where I would expect to find a file count) the value is always zero!!

Please help, very confused by this!



Accessing file on remote server


       I need help to achieve the following.
       I have integrated the Single Sign On to my webapplication. Service Provider(SP) is developing in .net platform and windows server.Identity Provider (IdP) is configured in apache and linux server.
       For authentication I am redirecting the user to IdP and authenticate at IdP and return back to my .net website. So I have user's database in IdP as a db file user.db (see the apache configuration below) for authenticating user.
          <Location /idp/Authn/RemoteUser>
               AuthType Basic

SSRS 2005 SP3 - Instr function with Global Variable fails in Subscriptions

Hi I have a very simple expression in a text box in my report:  INSTR(Globals!ReportServerUrl,"Report").  This expression should return the integer value of where the string "Report" appears in the Global variable for the ReportServerUrl.  Simple enough.  This works fine for generating the report directly through report manager, and in my case returns a value of 20. However when run as a subscription and emailed to myself the value returned is 0. This suggests that the search string does not appear in the Global variable. In the reportserver config file the URLroot tag contains the correct server address - http://myserver/reportserver. Does anyone know why i should be experiencing this issue with my subscriptions?  Your help would be much appreciated! Thanks Guy  Guy

accessing MSSQLServer on Windows with Simple File Sharing

I am running MS SQL Server Developer Ed. on Windows XP SP3 in workgroup(non-domained). Having read  in [1]: "NTLM Authentication: Challenge- Response mechanism. In the NTLM protocol, the client sends the user name to the server; the server generates and sends a challenge to the client; the client encrypts that challenge using the user’s password; and the client sends a response to the server.If it is a local user account, server validate user's response by looking into the Security Account Manager; if domain user account, server forward the response to domain controller for validating and retrive group policy of the user account, then construct an access token and establish a session for the use." I could not understand: What happens in the case of "Use Simple File Sharing (Recommended)" (Windows Explorer --> Tools --> Folder Options --> View --> Use Simple File Sharing-->)? IS server validate Windows user accounts with passwords in "Windows Authentication" mode? In other words, is there need to create user accounts for accessing server? I have never used simple file sharing before... PS. Is this mode available on server editions of Windowses? [1] Understanding Kerberos and NTLM authentication in SQL Server Connections http://blogs.msdn.com/b/sql_protocols/archive/2006/12/02/understanding-kerberos-and-nt

SSIS multiple data flows accessing the same raw file

I have multiple data flow tasks accessing the same raw file at virtually the same time.  I would like to know if the data flow tasks lock the raw file during read?  Can multiple data flow tasks read the same raw file at the same time.  I'm currently developing with a very small data set, but I would like to know if I should be concerned with the possibility of the data flow tasks competing for access to the same raw file. Thanks.

Respoce.Redirect from ashx file

Hi everyoneHow To  Redirect from httphandler(.ashx)  to an (.aspx) page in the same application ?Thanks.

how to pass value code behind to ashx file

Hi,i have generic handler file  ashx file , i want to pass value from my codebehind to ashx fileand i want to use switch case inside the ashx handle

Error when accessing an InfoPath file on a file share

Some users get an error when they try to open an InfoPath (2007) file which is location on a file share.  The users getting the error are from our South America domain.  All users, regardless of domain, have the same permissions to the file share folder and they can open and save other files on that file share, txt file, Excel file, etc.  They get this error when trying to open the Info Path file:  "InfoPath cannot create a new, blank form.  InfoPath cannot open the form.  to fix this problem, contact your system administrator.  The query cannot be run for the following data source:SoftwareList"

Accessing image file in local machine from server

 Hi i have a  .JPG file in my local machine which has  to be sent as body of SMTP mail. Path of image D://foldername//imagename.jpg The code I run is in the server m\c. I want it to access my local machine's d:\ folder to get the image file. But it is accessing the server m\c's d:\ folder. How can this be done? Thanks Amuda.RG  

Foreach File Enumerator - Use Variable to Set FileSpec Property

Hello All: Can anyone give guidance on how to set the mask for a Foreach File Enumerator programmatically? I have a DB that has a list of masks. I am retrieving that into an ADO recordset. For each record I retrieve the value into a variable. I would like to look at a directory and move all files that begin with the chars for each item in my recordset variable. TIA - Tom

Session State in ASHX file


Hi People,

I have been trying unsuccessfully to retrieve a Session varaible from within an ASHX file that i'm using to build an XML file.

What I am trying to achieve is quite simple really.

My ASHX file is used to dynamically build an XML file so that I can then bind it to a TreeView control later on. However the dynamic part isn't quite working because the ID that I need from the session seems to not be passed into the ASHX file.

I have tried using the following methods to do this:

1) Include interfaces IRequiresSessionState and IReadOnlySessionState

2) Tried accessing the value like this: Session["ID"] or context.Session["ID"] or HttpContext.Current.Session["ID"]

I am setting the Session variable in the MasterPage's code behind.

Can anyone help?



Cache vs Static variable


Well, I know the big difference, but one thing is confusing me. Cache works only on a single machine on webfarm and to make it globally we use Velocity or memcache.

So is static does same, or is it already work globally ?


Cache["someid"] = "value"; //this will only work on single machine cache,

static string abc = "value"; // will this work on single machine or globally ? 

static time variable


Hi all,

I'm not really much of a programmer but I've been working on something in visual web developer and VB...

I've got an asp.net page with a fileupload control and two buttons. One button is used to upload the file and then the other button does something else which involves accessing the file name of the uploaded file.

This is straight forward enough if you just use static text but I wanted to create a unique file name for the upload so thought about using a date/time value for this and delcaring it as a variable?

This works great but how does the second button then access this file name? If I use the same variable name declared earlier it just generates a new one especially if mins and secs were used?

I'm not sure if that makes sense? But I'm basically wanting to create a unique file name for the uploaded file and then store that in a variable so it can be accessed by the other button? Without the variable constantly updating to a new ID?

Thanks for any help.

ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend