System.UriFormatException:无效的 URI:无法解析主机名
突然我的网站上出现以下错误。它不访问数据库。这只是一个使用.NET 2.0 的简单网站。
我最近确实应用了可用的 Windows Server 2003 服务包。这会改变事情吗?
我应该补充一点,错误是随机出现和消失的,并且今天和昨天一直如此。我将其放置 5 分钟,错误就消失了。
“/”应用程序中的服务器错误。
无效 URI:无法解析主机名。描述:安 当前网页执行期间发生未处理的异常 要求。请查看堆栈跟踪以获取有关的更多信息 错误及其在代码中的起源。
异常详细信息:
System.UriFormatException:无效的 URI:无法使用主机名 已解析。
来源错误:
执行过程中产生了未处理的异常 当前的网络请求。有关原产地和地点的信息 可以使用下面的异常堆栈跟踪来识别异常。
堆栈跟踪:
[UriFormatException:无效的 URI:无法解析主机名。]
System.Uri.CreateThis(String uri, Boolean dontEscape, UriKind uriKind) +5367536 System.Uri.CreateUri(Uri baseUri, StringrelativeUri, Boolean dontEscape) +31 System.Uri..ctor(Uri baseUri, String relativeUri) +34 System.Net.HttpWebRequest.CheckResubmit(异常& e) +5300867[WebException:无法处理从 HTTP/HTTPS 协议到 其他不同的。] System.Net.HttpWebRequest.GetResponse() +5314029 System.Xml.XmlDownloadManager.GetNonFileStream(Uri uri,ICredentials 凭据)+69
System.Xml.XmlDownloadManager.GetStream(Uri uri, ICredentials 凭据)+3929371 System.Xml.XmlUrlResolver.GetEntity(Uri 绝对Uri,字符串角色,返回对象类型)+54
System.Xml.XmlTextReaderImpl.OpenUrlDelegate(对象 xmlResolver)+74
System.Threading.CompressedStack.runTryCode(Object userData) +70
System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode 代码、CleanupCode backoutCode、对象 userData) +0
System.Threading.CompressedStack.Run(CompressedStack 压缩堆栈, ContextCallback回调,对象状态)+108
System.Xml.XmlTextReaderImpl.OpenUrl() +186
System.Xml.XmlTextReaderImpl.Read() +208
System.Xml.XmlLoader.Load(XmlDocument 文档,XmlReader 阅读器,布尔值 保留空白)+112 System.Xml.XmlDocument.Load(XmlReader 读者)+108
System.Web.UI.WebControls.XmlDataSource.PopulateXmlDocument(XmlDocument 文档、CacheDependency& dataCacheDependency、CacheDependency& 转换缓存依赖项)+303
System.Web.UI.WebControls.XmlDataSource.GetXmlDocument() +153
System.Web.UI.WebControls.XmlDataSourceView.ExecuteSelect(DataSourceSelectArguments 参数)+29 System.Web.UI.WebControls.BaseDataList.GetData() +39 System.Web.UI.WebControls.DataList.CreateControlHierarchy(布尔值 使用数据源)+264
System.Web.UI.WebControls.BaseDataList.OnDataBinding(EventArgs e) +55 System.Web.UI.WebControls.BaseDataList.DataBind() +75
System.Web.UI.WebControls.BaseDataList.EnsureDataBound() +55
System.Web.UI.WebControls.BaseDataList.CreateChildControls() +65
System.Web.UI.Control.EnsureChildControls() +97
System.Web.UI.Control.PreRenderRecursiveInternal() +53
System.Web.UI.Control.PreRenderRecursiveInternal() +202
System.Web.UI.Control.PreRenderRecursiveInternal() +202
System.Web.UI.Control.PreRenderRecursiveInternal() +202
System.Web.UI.Control.PreRenderRecursiveInternal() +202
System.Web.UI.Page.ProcessRequestMain(布尔值 includeStagesBeforeAsyncPoint、布尔值 includeStagesAfterAsyncPoint) +4588
All of a sudden I'm getting the following error on my website. It doesn't access a database. It's just a simple website using .NET 2.0.
I did recently apply the available windows server 2003 service packs. Could that have changed things?
I should add that the error randomly comes and goes and has been doing so for today and yesterday. I leave it for 5 minutes and the error is gone.
Server Error in '/' Application.
Invalid URI: The hostname could not be parsed. 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.UriFormatException: Invalid URI: The hostname could not be
parsed.
Source Error:
An unhandled exception was generated during the execution of the
current web request. Information regarding the origin and location of
the exception can be identified using the exception stack trace below.
Stack Trace:
[UriFormatException: Invalid URI: The hostname could not be parsed.]
System.Uri.CreateThis(String uri, Boolean dontEscape, UriKind uriKind)
+5367536 System.Uri.CreateUri(Uri baseUri, String relativeUri, Boolean dontEscape) +31 System.Uri..ctor(Uri baseUri, String
relativeUri) +34 System.Net.HttpWebRequest.CheckResubmit(Exception&
e) +5300867[WebException: Cannot handle redirect from HTTP/HTTPS protocols to
other dissimilar ones.] System.Net.HttpWebRequest.GetResponse()
+5314029 System.Xml.XmlDownloadManager.GetNonFileStream(Uri uri, ICredentials credentials) +69
System.Xml.XmlDownloadManager.GetStream(Uri uri, ICredentials
credentials) +3929371 System.Xml.XmlUrlResolver.GetEntity(Uri
absoluteUri, String role, Type ofObjectToReturn) +54
System.Xml.XmlTextReaderImpl.OpenUrlDelegate(Object xmlResolver) +74
System.Threading.CompressedStack.runTryCode(Object userData) +70
System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode
code, CleanupCode backoutCode, Object userData) +0
System.Threading.CompressedStack.Run(CompressedStack compressedStack,
ContextCallback callback, Object state) +108
System.Xml.XmlTextReaderImpl.OpenUrl() +186
System.Xml.XmlTextReaderImpl.Read() +208
System.Xml.XmlLoader.Load(XmlDocument doc, XmlReader reader, Boolean
preserveWhitespace) +112 System.Xml.XmlDocument.Load(XmlReader
reader) +108
System.Web.UI.WebControls.XmlDataSource.PopulateXmlDocument(XmlDocument
document, CacheDependency& dataCacheDependency, CacheDependency&
transformCacheDependency) +303
System.Web.UI.WebControls.XmlDataSource.GetXmlDocument() +153
System.Web.UI.WebControls.XmlDataSourceView.ExecuteSelect(DataSourceSelectArguments
arguments) +29 System.Web.UI.WebControls.BaseDataList.GetData() +39
System.Web.UI.WebControls.DataList.CreateControlHierarchy(Boolean
useDataSource) +264
System.Web.UI.WebControls.BaseDataList.OnDataBinding(EventArgs e) +55
System.Web.UI.WebControls.BaseDataList.DataBind() +75
System.Web.UI.WebControls.BaseDataList.EnsureDataBound() +55
System.Web.UI.WebControls.BaseDataList.CreateChildControls() +65
System.Web.UI.Control.EnsureChildControls() +97
System.Web.UI.Control.PreRenderRecursiveInternal() +53
System.Web.UI.Control.PreRenderRecursiveInternal() +202
System.Web.UI.Control.PreRenderRecursiveInternal() +202
System.Web.UI.Control.PreRenderRecursiveInternal() +202
System.Web.UI.Control.PreRenderRecursiveInternal() +202
System.Web.UI.Page.ProcessRequestMain(Boolean
includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
+4588
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Uri.Create 和 Uri.TryCreate 中存在一些错误,允许它们创建随后无法解析的无效 URI。我时常遇到这个问题,但无法追踪导致它的 url 字符串。我在此处发布了一些相关内容。
如果您有一个网址列表,并且知道其中一个网址导致了问题(我没有那么奢侈,因为我在没有保存页面文本的网络抓取中遇到了这种情况),您可以使用以下命令找到错误像这样的伪代码:
如果您可以识别一些导致此异常的网址,我当然希望看到它们。
There are some bugs in Uri.Create and Uri.TryCreate that allow them to create invalid URIs that cannot subsequently be parsed. I've run into this from time to time, but have been unable to track down the url strings that cause it. I posted a little bit about it here.
If you have a list of urls and know that one of them causes the problem (I didn't have that luxury, as I encountered this in a Web crawl where I wasn't saving the page text), you can find the error with something like this pseudocode:
If you can identify some urls that cause this exception, I'd sure like to see them.