[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1517
  • Last Modified:

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

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
tia_kamakshi
Asked:
tia_kamakshi
1 Solution
 
TimCotteeCommented:
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
 
tia_kamakshiAuthor Commented:
Thanks
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now