Web Services tempDirectory编译配置

5kgi1eie  于 2022-11-15  发布在  其他
关注(0)|答案(4)|浏览(122)

我想将<compilation tempDirectory="MyPath"/>添加到我的Web服务的web.config中。
可以指定相对路径吗?还是只能使用绝对路径?

2nbm6dog

2nbm6dog1#

后藤webconfig文件,仅删除路径值。
这通常是在将文件从一个域移动到另一个域时导致的。

w8f9ii69

w8f9ii692#

tempDirectory开始,
指定编译期间用于临时文件存储的目录。
我认为你最好的选择是绝对路径;但是,你可以试试这样的相对关系:

<compilation tempDirectory="Default Web Site/YourApp"/>
yvt65v4c

yvt65v4c3#

临时目录的处理方式如下:

if ((compilationSection != null) && !string.IsNullOrEmpty(compilationSection.TempDirectory))
{
    path = compilationSection.TempDirectory;
    compilationSection.GetTempDirectoryErrorInfo(out tempDirAttribName, out configFileName, out configLineNumber);
}
if (path != null)
{
    path = path.Trim();
    if (!Path.IsPathRooted(path))
    {
        path = null;
    }
    else
    {
        try
        {
            path = new DirectoryInfo(path).FullName;
        }
        catch
        {
            path = null;
        }
    }
    if (path == null)
    {
        throw new ConfigurationErrorsException(SR.GetString("Invalid_temp_directory", new object[] { tempDirAttribName }), configFileName, configLineNumber);
    }

其中,如果(路径[0]为“\”或“/”)或(路径[1]为“:”),则IsPathRooted返回true
设置相对路径:

<compilation tempDirectory="/Default Web Site/YourApp"/>
ndasle7k

ndasle7k4#

无法指定相对路径,因为错误消息也明确指出。

相关问题