突然之间,我在我的网站上得到了以下错误。它不能访问数据库。它只是一个使用.NET 2.0的简单网站。
我最近确实应用了可用的windows server 2003 service。这能改变一切吗?
我要补充的是,这个错误是随机的,今天和昨天都是如此。我离开它5分钟,错误就消失了。
“/”应用程序中的
服务器错误。
无效URI:无法解析主机名。描述:在执行当前web请求时发生了未处理的异常。请查看堆栈跟踪以获得有关错误的更多信息,以及它起源于代码的位置。
例外细节:
System.UriFormatException:无效URI:无法解析主机名。
源错误:
在执行当前web请求时生成未处理的异常。有关异常的起源和位置的信息可以使用下面的异常堆栈跟踪来标识。
堆栈跟踪:
UriFormatException:无效URI:无法解析主机名。
+5367536 System.Net.HttpWebRequest.CheckResubmit(Exception& (Uri baseUri,String relativeUri,Boolean ) +31 System.Uri..ctor(Uri baseUri,String relativeUri) +34 System.Uri.CreateUri e) +5300867
WebException:无法处理从HTTP/HTTPS协议重定向到其他不同协议的问题。+5314029 System.Xml.XmlDownloadManager.GetNonFileStream(Uri uri,ICredentials凭据) +69
System.Xml.XmlDownloadManager.GetStream(Uri uri,ICredentials凭据) +3929371 System.Xml.XmlUrlResolver.GetEntity(Uri absoluteUri,String角色,类型ofObjectToReturn) +54
System.Xml.XmlTextReaderImpl.OpenUrlDelegate(Object xmlResolver) +74
System.Threading.CompressedStack.runTryCode(Object userData) +70
System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode代码,CleanupCode backoutCode,Object userData) +0
System.Threading.CompressedStack.Run(CompressedStack compressedStack,ContextCallback回调,对象状态) +108
System.Xml.XmlTextReaderImpl.OpenUrl() +186
System.Xml.XmlTextReaderImpl.Read() +208
System.Xml.XmlLoader.Load(XmlDocument文档,XmlReader阅读器,布尔preserveWhitespace) +112 System.Xml.XmlDocument.Load(XmlReader阅读器) +108
System.Web.UI.WebControls.XmlDataSource.PopulateXmlDocument(XmlDocument文档,CacheDependency& dataCacheDependency,CacheDependency& transformCacheDependency) +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(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(布尔型includeStagesBeforeAsyncPoint,布尔型includeStagesAfterAsyncPoint) +4588
发布于 2010-05-11 15:31:11
Uri.Create和Uri.TryCreate中有一些bug允许它们创建无效的URI,这些URI随后无法被解析。我经常遇到这种情况,但是无法找到导致这种情况的url字符串。我贴了一点关于它的here。
如果您有一个urls列表,并且知道其中一个urls导致了问题(我没有这种特权,因为我在Web爬虫中遇到了这个问题,而我并没有保存页面文本),那么您可以使用类似于以下伪代码的内容找到错误:
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);
}
}
如果您能够识别导致此异常的一些urls,我肯定会看到它们。
https://stackoverflow.com/questions/2814951
复制相似问题