Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/260.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何获取ASP.NET应用程序路径?_C#_Asp.net Mvc - Fatal编程技术网

C# 如何获取ASP.NET应用程序路径?

C# 如何获取ASP.NET应用程序路径?,c#,asp.net-mvc,C#,Asp.net Mvc,我有自己的siteMapProvider,我需要物理文件路径来初始化它,但我不能使用HttpContext来进行初始化,因为IIS 7将引发异常: fileName = HttpContext.Current.Server.MapPath(fileName); 在没有HttpContext的情况下如何执行MapPath?查看以下内容:(来自MSDN)您也可以尝试: HttpContext.Current.Request.PhysicalApplicationPath 请阅读我的问题:我不能使

我有自己的siteMapProvider,我需要物理文件路径来初始化它,但我不能使用HttpContext来进行初始化,因为IIS 7将引发异常:

fileName = HttpContext.Current.Server.MapPath(fileName);

在没有HttpContext的情况下如何执行MapPath?

查看以下内容:(来自MSDN)

您也可以尝试:

HttpContext.Current.Request.PhysicalApplicationPath

请阅读我的问题:我不能使用HttpContext来做这件事,因为IIS 7会抛出异常这个解决方案对我很有效,非常感谢:)为什么IIS 7会抛出异常?。