开发者

HTTP Error 401.3 on created .gz file

I have method to compress file with GZip:

public static void CompressFile(string filePath)
{

      string compressedFilePath = Path.GetTempFileName();
      using (FileStream compressedFileStream = new FileStream(compressedFilePath, FileMode.Append, FileSystemRights.Write, FileShare.Write, BufferSize, FileOptions.None))
      {

        GZipStream gzipStream = new GZipStream(compressedFileStream, CompressionMode.Compress);
        using (FileStream uncompressedFileStream = new File开发者_如何学运维Stream(filePath, FileMode.Open, FileAccess.Read, FileShare.Read))
        {
          int offset = 0;
          while (true)
          {
            byte[] buffer = new byte[offset + BufferSize];
            int bytesRead = uncompressedFileStream.Read(buffer, offset, BufferSize);
            if (bytesRead == 0)
              break;

            gzipStream.Write(buffer, offset, bytesRead);
            offset += bytesRead;
          }
        }
        gzipStream.Close();
      }

      File.Delete(filePath);
      File.Move(compressedFilePath, filePath);
 }

My problem is, that on testing server (Win08 R2) it creates file and it can be downloaded via browser, but on webhosting server (older Win08 R1) it also creates file, but if i want to download it, access denied exception is thrown. Differences are in file permission. On R2 server has access to file Application pool identity (e.g. "MyWebSite"), but on R1 only IIS_IUSRS with "Special permission".


Ensure you have a MIME type added for the .gz extension in IIS configuration. I think this may cause the issue you are referring to.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜