[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Access Httpcontext 's Application Object in a class or control

Posted on 2006-10-23
4
Medium Priority
?
267 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 2000 total points
ID: 17819563
I think you want

HttpContext.Current.Application["ConnectionString"]
0

Featured Post

What’s Wrong with Your Cloud Strategy ?

Even as many CIOs are embracing a cloud-first strategy, the reality is that moving to the cloud is a lengthy process and the end-state is likely to be a blend of multiple clouds—public and private. Learn why multicloud solutions matter in this webinar by Nimble Storage.

Question has a verified solution.

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

In order to hide the "ugly" records selectors (triangles) in the rowheaders, here are some suggestions. Microsoft doesn't have a direct method/property to do it. You can only hide the rowheader column. First solution, the easy way The first sol…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
Suggested Courses

656 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