Invalid URI: The hostname could not be parsed

S

SevDer

Do you have any idea why I am getting the following error?

Invalid URI: The hostname could not be parsed.
Inner stack trace
at System.Uri.Parse()
at System.Uri..ctor(String uriString, Boolean dontEscape)
at System.Uri..ctor(String uriString)
at System.Web.HttpRequest.get_UrlReferrer()
at DotNetNuke.CDefault.ManageRequest()
at DotNetNuke.CDefault.Page_Init(Object sender, EventArgs e)
at System.Web.UI.Control.OnInit(EventArgs e)
at System.Web.UI.Control.InitRecursive(Control namingContainer)
at System.Web.UI.Page.ProcessRequestMain()


Currently we experience this around 100 times a day.

Thanks for the information in advance
 
S

S. Justin Gengo

Do you have the time of the error?

Have you checked your weblogs to see if you can see any invalid requests
coming through at the same time?

That may be the place to begin...

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
 
B

Bruce Barker

the browser/proxy/firewall is free to put anything it wants in the
UrlReferrer header, so Request.UrlReferrer will not necessarily return a
valid url, thus the thrown execption.

-- bruce (sqlwork.com)
 
S

SevDer

Actually I didn't try this one. I will have a look to that too.
However the interesting thing is it fails at Microsoft's code part not mine.

My code is as follows:
' URL Referrer

Dim URLReferrer As String = ""

If Not Request.UrlReferrer Is Nothing Then

URLReferrer = Request.UrlReferrer.ToString()

End If



Thanks
 
S

SevDer

That is fine but I have the problem when I am checking Request.UrlReferrer
against null.
Instead of being null, it throws an exception.
 
J

Juan T. Llibre

1.
A value of type System.Uri cannot be converted to String.

2.
Have you tried using
URLReferrer = Request.ServerVariables("http_referer")

?
 
S

Steven Cheng[MSFT]

Hi SevDer,

So the problem is just caused by the following uri you mentioned:
===========
http://www.china-airline.com/search.asp?Keyword=China+Airlines&Site=d3
d3LmNoaW5hLWFpcmxpbmUuY29t
==========

You can get the problem also through the below code:

string str =
"http://www.china-airline.com/search.asp?Keyword=China+Airlines&Site=d
3d3LmNoaW5hLWFpcmxpbmUuY29t";

Uri uri = new Uri(str);

And as the exception message mentioned, the proboem is the Host name, it
seems that the
"www%2echina%2dairline%2ecom" is incorrectly encoded while the correct one
should be

www.china-airline.com (is not urlencoded).

Also, from the

http://www.china-airline.com/search.asp?Keyword=China+Airlines&Site=d3
d3LmNoaW5hLWFpcmxpbmUuY29t

we can find that the request is sent by the search page on the
china-airline site, so the urlreferer is possibly set by code
programmatically.

Thanks,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security





--------------------
| Reply-To: "SevDer" <[email protected]>
| From: "SevDer" <[email protected]>
| References: <[email protected]>
<#[email protected]>
<[email protected]>
| Subject: Re: Invalid URI: The hostname could not be parsed
| Date: Thu, 6 Oct 2005 17:21:39 -0400
| Lines: 102
| Organization: http://www.sevder.com
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.3790.1830
| X-RFC2646: Format=Flowed; Response
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.1830
| Message-ID: <[email protected]>
| Newsgroups: microsoft.public.dotnet.framework.aspnet
| NNTP-Posting-Host: mail.dtfares.com 68.167.20.2
| Path: TK2MSFTNGXA01.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP14.phx.gbl
| Xref: TK2MSFTNGXA01.phx.gbl
microsoft.public.dotnet.framework.aspnet:129604
| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
|
| I caught the referrer.
|
| These guys are coming as
|
http://www.china-airline.com/search.asp?Keyword=China+Airlines&Site=d3
d3LmNoaW5hLWFpcmxpbmUuY29t
|
| But their browsers are fine. They are all MSIE 6.0 browsers.
| I didn't get why this is happening!
|
| Do you have any idea? Can it be like a software that uses some sites to
get
| links or so?
| So that it does not send the url properly?
|
| --
|
| SevDer
| http://www.sevder.com
| A new .NET Source For .NET Developers
|
|
| | > Actually I didn't try this one. I will have a look to that too.
| > However the interesting thing is it fails at Microsoft's code part not
| > mine.
| >
| > My code is as follows:
| > ' URL Referrer
| >
| > Dim URLReferrer As String = ""
| >
| > If Not Request.UrlReferrer Is Nothing Then
| >
| > URLReferrer = Request.UrlReferrer.ToString()
| >
| > End If
| >
| >
| >
| > Thanks
| >
| >
| > --
| >
| > SevDer
| > http://www.sevder.com
| > A new .NET Source For .NET Developers
| >
| >
| > message | >> Do you have the time of the error?
| >>
| >> Have you checked your weblogs to see if you can see any invalid
requests
| >> coming through at the same time?
| >>
| >> That may be the place to begin...
| >>
| >> --
| >> Sincerely,
| >>
| >> S. Justin Gengo, MCP
| >> Web Developer / Programmer
| >>
| >> www.aboutfortunate.com
| >>
| >> "Out of chaos comes order."
| >> Nietzsche
| >> | >>> Do you have any idea why I am getting the following error?
| >>>
| >>> Invalid URI: The hostname could not be parsed.
| >>> Inner stack trace
| >>> at System.Uri.Parse()
| >>> at System.Uri..ctor(String uriString, Boolean dontEscape)
| >>> at System.Uri..ctor(String uriString)
| >>> at System.Web.HttpRequest.get_UrlReferrer()
| >>> at DotNetNuke.CDefault.ManageRequest()
| >>> at DotNetNuke.CDefault.Page_Init(Object sender, EventArgs e)
| >>> at System.Web.UI.Control.OnInit(EventArgs e)
| >>> at System.Web.UI.Control.InitRecursive(Control namingContainer)
| >>> at System.Web.UI.Page.ProcessRequestMain()
| >>>
| >>>
| >>> Currently we experience this around 100 times a day.
| >>>
| >>> Thanks for the information in advance
| >>>
| >>> --
| >>>
| >>> SevDer
| >>> http://www.sevder.com
| >>> A new .NET Source For .NET Developers
| >>>
| >>>
| >>>
| >>
| >>
| >
| >
|
|
|
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top