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
Solved

The type or namespace name 'Request' could not be found (are you missing a using directive or an assembly reference?)

Posted on 2008-06-18
2
1,475 Views
Last Modified: 2010-04-21
Hi ,

I am working on ASP.net 1.1, C#

In the CS file I have handled the exception handling.

There I want to add the referrer page if any

I added but I get the error

The type or namespace name 'Request' could not be found (are you missing a using directive or an assembly reference?)


With below code



using System;
using System.Configuration;
using System.Web.Mail;

string ErrFullMessage = string.Empty;


if(Request.UrlReferrer != null)
{
      ErrFullMessage = ErrFullMessage+"<br> Url Referrer"+Request.UrlReferrer.ToString();
}


I also tried adding the assemblies but doesn't work


using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;

Please guide

Thanks
0
Comment
Question by:tia_kamakshi
2 Comments
 
LVL 43

Accepted Solution

by:
TimCottee earned 500 total points
ID: 21811829
Hello tia_kamakshi,

I assume that this is not a code-behind file.

In this case you need to use:

If(HttpContext.Current.Request.UrlReferrer !=null)

To explicitly reference the current request object. The request/server/response objects are normally available only to code-behind because they are partial classes and inherit the Page object which has these objects in it. If you need to refer to them from elsewhere use HttpContext.Current.Request etc.

Regards,

TimCottee
0
 

Author Closing Comment

by:tia_kamakshi
ID: 31468293
Thanks
0

Featured Post

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

860 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