If you try to use a context object in code (i.e. Response, Request, Server, etc.) that doesn't inherit from System.Web.UI.Page, you will receive a runtime error. To use a context object under those circumstances you will need
to use System.Web.HttpContext.Current.<Context Object>.
StrongTypes
All-Star
30801 Points
6013 Posts
ASPInsiders
Why am I not able to access the context objects in my code?
Feb 17, 2006 01:14 PM|LINK
If you try to use a context object in code (i.e. Response, Request, Server, etc.) that doesn't inherit from System.Web.UI.Page, you will receive a runtime error. To use a context object under those circumstances you will need to use System.Web.HttpContext.Current.<Context Object>.
Examples:
System.Web.HttpContext.Current.Request.QueryString["SomeQueryString"]
System.Web.HttpContext.Current.Response.Redirect("SomePage.aspx")
techieman
Member
110 Points
23 Posts
Re: Why am I not able to access the context objects in my code?
Feb 24, 2006 10:55 AM|LINK
I m using following line of code still it gives error :
System.Web.HttpContext.Current.Request.UrlReferrer.ToString();
StrongTypes
All-Star
30801 Points
6013 Posts
ASPInsiders
Re: Why am I not able to access the context objects in my code?
Feb 24, 2006 12:45 PM|LINK
I m using following line of code still it gives error :
System.Web.HttpContext.Current.Request.UrlReferrer.ToString()
If that ones blowing up, you may want to try System.Web.HttpContext.Current.Request.ServerVariables["HTTP_REFERER"];
HTH,
Ryan