Link to home
Start Free TrialLog in
Avatar of FFagbohunka
FFagbohunka

asked on

Access Httpcontext 's Application Object in a class or control

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; }
            }
}
Avatar of ostdp
ostdp

Try

context.Response.Write( context.Application["ConnectionString"]);
ASKER CERTIFIED SOLUTION
Avatar of Paul_Tew
Paul_Tew

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial