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,462 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
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.
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…
As a trusted technology advisor to your customers you are likely getting the daily question of, ‘should I put this in the cloud?’ As customer demands for cloud services increases, companies will see a shift from traditional buying patterns to new…

867 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

22 Experts available now in Live!

Get 1:1 Help Now