首页 文章

不支持路径的格式

提问于
浏览
0

我添加了一个新的网站和页面的onLoad事件我尝试加载Xml

public partial class _Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        XmlDocument xmlDoc = new XmlDocument();
        xmlDoc.Load(@"‪D:\languages\Lang-Ru.xml"); //ERROR
    }
}

当我启动该网站时,出现错误:

mscorlib.dll中出现“System.NotSupportedException”类型的异常但未在用户代码中处理附加信息:不支持给定路径的格式

堆栈跟踪:

вSystem.Security.Util.StringExpressionSet.CanonicalizePath(String path,Boolean needFullPath)вSystem.Security.Util.StringExpressionSet.CreateListFromExpressions(String [] str,Boolean needFullPath)вSystem.Security.Permissions.FileIOPermission.AddPathList(FileIOPermissionAccess access) ,AccessControlActions控件,String [] pathListOrig,Boolean checkForDuplicates,Boolean needFullPath,Boolean copyPathList)System.IO.Path.GetFullPath(String path)вSystem.Xml.XmlResolver.ResolveUri(Uri baseUri,String relativeUri)вSystem.Xml . XmlTextReaderImpl..ctor(String url,XmlNameTable nt)вSystem.Xml.XmlDocument.Load(String filename)в_Default.Page_Load(Object sender,EventArgs e)вd:\ sample \ Default.aspx.cs:строка14вSystem .Web.UI.Control.LoadRecursive()вSystem.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint,Boolean includeStagesAfterAsyncPoint)

有谁能够帮我?也许IIS中存在一些非法设置 .

1 回答

  • 0

    网站无法访问本地驱动器 . 他们只能访问存储HTML的区域或其下方的位置 . 这可能带来安全风险 .

    您希望将xml文件添加到网站的内容区域,然后使用该位置的相对路径 .

    上述限制有很多种方法 - 但这样做的理由很少 . 如果要访问XML内容,最好的方法是让IIs软件管理文件的权限和访问权限 . 您不太可能将自己暴露给安全漏洞 .

相关问题