Re: Problems with HTTP_REFERER
- From: "Mark Fitzpatrick" <markfitz@xxxxxxxxxx>
- Date: Tue, 19 Jul 2005 16:17:03 -0500
All it's saying is that there is no value for the HTTP_Referer item, that
means that the array item will be a null value. It's throwing an error
because you cannot convert a null value into an uppercase string, or any
string for that matter.
You have to first check and see if it's null before you attempt to access it
if(Request.ServerVariables["HTTP_REFERER"] != null)
{
// then you can do something
}
If you have to count on the referer information don't, you don't always
receive information so a lot of the times you'll simply have a null value
here.
Hope this helps,
Mark Fitzpatrick
Microsoft MVP - FrontPage
"Paperback Writer" <newsgroupms@xxxxxxxxx> wrote in message
news:u$XH1VKjFHA.1148@xxxxxxxxxxxxxxxxxxxxxxx
> Hi, I have the following code in my ASPX:
> private string pagina =
> System.IO.Path.GetFileName(System.Web.HttpContext.Current.Request.ServerVariables["HTTP_REFERER"].ToUpper());
>
> The problem is it: When i call this page directly i get an error:
>
>
> Object reference not set to an instance of an object.
> Description: An unhandled exception occurred during the execution of the
> current web request. Please review the stack trace for more information
> about the error and where it originated in the code.
>
> Exception Details: System.NullReferenceException: Object reference not set
> to an instance of an object.
>
>
>
> I really need that, but i do not know how to accomplish this. Does someone
> can help me ?
>
>
.
- References:
- Problems with HTTP_REFERER
- From: Paperback Writer
- Problems with HTTP_REFERER
- Prev by Date: RE: Adding a onload event to the body section.
- Next by Date: Re: HTML Extension for ASP.NET 2.0
- Previous by thread: Re: Problems with HTTP_REFERER
- Next by thread: Re: Problems with HTTP_REFERER
- Index(es):
Relevant Pages
|