Solved

Access Httpcontext 's Application Object in a class or control

Posted on 2006-10-23
4
258 Views
Last Modified: 2010-04-16
Hi Guys,


I am writing a class that will be used to render Html  on the web . I  need to use the HTTPContext  within the class but I get a compiler error when I try it gets to the Context.Application("ConnectionString"). Basically I am not able to retrieve my application object variables from this class. Here is the code, Please help anyone

 I have the following in the web reference
System.Web
System.XML
System.Design
System.Drawing Design
System




using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Drawing;
using System.Drawing.Design;
 


 
 

namespace PBControls
{
      /// <summary>
      /// Summary description for Class1.
      /// </summary>
      /// import System.*;
      
      using PBSQLData;
      using PBSettings;
      
      

 
      public   class myclass: IHttpHandler
               
      
      {
           
            public myclass() {}


            public void ProcessRequest(HttpContext context)
            {
                  context.Response.Write("<H1>This is an HttpHandler Test.</H1>");      
                  context.Response.Write("<p>Your Browser:</p>");
                  context.Response.Write("Type: " + context.Request.Browser.Type + "<br>");
                                                //Get An Error Here
                  context.Response.Write( context.Application("ConnectionString"));
                  
                  
            }

            // Override the IsReusable property.
            public bool IsReusable
            {
                  get { return true; }
            }
}
0
Comment
Question by:FFagbohunka
4 Comments
 
LVL 4

Expert Comment

by:ostdp
ID: 17791162
Try

context.Response.Write( context.Application["ConnectionString"]);
0
 
LVL 1

Accepted Solution

by:
Paul_Tew earned 500 total points
ID: 17819563
I think you want

HttpContext.Current.Application["ConnectionString"]
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

708 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

16 Experts available now in Live!

Get 1:1 Help Now