Solved

Access Httpcontext 's Application Object in a class or control

Posted on 2006-10-23
4
265 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

Question has a verified solution.

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

This article describes a simple method to resize a control at runtime.  It includes ready-to-use source code and a complete sample demonstration application.  We'll also talk about C# Extension Methods. Introduction In one of my applications…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

688 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