I have a simple ASP.NET Core 6 MVC web app to test viewing various files. The tests were performed in Visual Studio 2022 on localhost.
The test steps include:
- Using a sample file 
example03.docxand save it in.htmformat. - It created 2 items 
example03.htmand a folderexample03_files - Copied the file and folder to 
/wwwroot/filesfolder - In the app, in the 
HomeController, add an action methodViewWordFile(see CODE #1) - Created a view 
ViewWordFile.cshtml(see CODE #2) - Test the code and everything worked as expected
 
I encountered problems after trying to compress the example03.htm and related folder into example03.zip file. I then tried to unzip that file in a ViewWordFile action method (see details in problem description section below)
CODE #1:
public IActionResult ViewWordFile()
{
    return View();
}
CODE #2:
@{
    ViewData["Title"] = "View Office File";
}
<div class="container">
    <h3>View MS Word Document</h3>
    <p>
    <div class="row text-center">
        <iframe src='https://localhost:7131/files/example03.htm' width='100%' height='650px' frameborder='0'></iframe>
    </div>
    </p>
</div>
Problem description:
- Added 2 subfolders 
/wwwroot/files/zippedand/wwwroot/files/unzip - Manually created zip file 
example03.zipand copied it to the/files/zippedfolder - In order to decompress the zip file, I added a method 
unpackFilein theHomeController(see CODE #3) - Modify the 
ViewWordFileaction method (see CODE 4) - When trace the code during execution, the unzip worked fine and unzipped files were placed in the 
/files/unzipfolder - After these changes, the 
ViewWordFileaction stopped working. During tracking, I could see the view was activated, when I put a breakpoint in the code block at the top. But, nothing was displayed. It looked like it was still at home page. - I thought it might be a file permission issue. I removed code calling 
UnpackFileinViewWordFileaction (as in CODE #3) and keep using files in/unzipfolder. The page started working again. It showed file permission was not the actual problem. - I suspect there was something with calling 
ZipFile.ExtractToDirectory. I changed code to call this method inside ofViewWordFileaction (see CODE #5). The problem happened again and page stopped working. 
It seemed that the ZipFile method interfered with the view. But I was unable to figure out the actual reason.
Any help or suggestions for troubleshooting will be greatly appreciated.
CODE #3
private bool UnpackFile (string zipFile, string unzipDir)
{
    bool isOk = false;
    if (System.IO.File.Exists(zipFile))
    {
        ZipFile.ExtractToDirectory(zipFile, unzipDir, true);
        isOk = true;
    }
    return true;
}
CODE #4
public IActionResult ViewWordFile()
{
    string zipFile = Path.Combine(_hostEnv.WebRootPath, "files/zipped", "example03.zip");
    string unzipDir = Path.Combine(_hostEnv.WebRootPath, "files/unzip");
    UnpackFile(zipFile, unzipDir);
    return View();
}
CODE #5
public IActionResult ViewWordFile()
{
    string zipFile = Path.Combine(_hostEnv.WebRootPath, "files/zipped", "example03.zip");
    string unzipDir = Path.Combine(_hostEnv.WebRootPath, "files/unzip");
    ZipFile.ExtractToDirectory(zipFile, unzipDir, true);
    return View();
}