gpt4 book ai didi

.net - 系统UriFormatException : Invalid URI: The hostname could not be parsed

转载 作者:行者123 更新时间:2023-12-02 03:34:30 27 4
gpt4 key购买 nike

我的网站突然出现以下错误。它不访问数据库。这只是一个使用 .NET 2.0 的简单网站。

我最近应用了可用的 Windows Server 2003 服务包。这会改变事情吗?

我应该补充一点,错误是随机出现和消失的,并且今天和昨天一直如此。我将其放置 5 分钟,错误就消失了。

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.

异常详细信息:

System.UriFormatException: Invalid URI: The hostname could not be parsed.

来源错误:

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.

堆栈跟踪:

[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

最佳答案

Uri.Create 和 Uri.TryCreate 中存在一些错误,允许它们创建随后无法解析的无效 URI。我时常遇到这个问题,但无法追踪导致它的 url 字符串。我发布了一些相关内容here .

如果您有一个网址列表,并且知道其中一个网址会导致问题(我没有那么奢侈,因为我在没有保存页面文本的网络抓取中遇到了这种情况),您可以找到类似伪代码的错误:

while not end of file
{
string url = read from file
Uri uri = new Uri(url);
try
{
string host = uri.Host;
}
catch (UriFormatException)
{
Console.WriteLine("Bad url: {0}", url);
}
}

如果您可以识别一些导致此异常的网址,我肯定希望看到它们。

关于.net - 系统UriFormatException : Invalid URI: The hostname could not be parsed,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2814951/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com