Skip to content

update process keeps repeating #738

Open
@neominky

Description

@neominky

We are encountering an incomprehensible issue where the update process keeps repeating.

On the customer's PC, we observe that updates continue to repeat.
I also noticed this issue on my own PC, and it seemed to be resolved by adding ResponseCache.
However, the issue still persists on several of the customer's PCs.

The server is running on IIS with .NET 9. The client is installed using a Windows Installer and updated via AutoUpdater.NET.
Below is part of the server-side code:

[HttpGet("{tenantName}/{MacAddress}/{AppId}/Download")]
[DontWrapResult]
[ResponseCache(NoStore = true, Location = ResponseCacheLocation.None, Duration = 0)]
public async Task DownloadAsync([FromRoute] string tenantName, [FromRoute] string MacAddress, [FromRoute] string AppId)
{
    HttpContext.Response.Clear();
    HttpContext.Response.ContentType = "application/octet-stream";
    HttpContext.Response.Headers.Append("Content-Disposition", $"attachment; filename=\"{System.IO.Path.GetFileName(deploy.FilePath!)}\"");
    HttpContext.Response.Headers.Append("Content-Length", fileinfo.Length.ToString());
    HttpContext.Response.Headers.Append("Content-Transfer-Encoding", "binary");
    HttpContext.Response.Headers.Append("Cache-Control", "no-store, no-cache, must-revalidate, max-age=0");
    HttpContext.Response.Headers.Append("Pragma", "no-cache");
    HttpContext.Response.Headers.Append("Expires", "0");

    await HttpContext.Response.SendFileAsync(deploy.FilePath);
}

Although I used ResponseCache to prevent caching, it didn’t solve the problem, so I added the headers manually.
I confirmed that the headers are indeed being sent.

In the AutoUpdater.cs, I also found the following code:

internal static MyWebClient GetWebClient(Uri uri, IAuthentication basicAuthentication)
{
    var webClient = new MyWebClient
    {
        CachePolicy = new RequestCachePolicy(RequestCacheLevel.NoCacheNoStore)
    };

    if (Proxy != null)
    {
        webClient.Proxy = Proxy;
    }

    if (uri.Scheme.Equals(Uri.UriSchemeFtp))
    {
        webClient.Credentials = FtpCredentials;
    }
    else
    {
        basicAuthentication?.Apply(ref webClient);
        webClient.Headers[HttpRequestHeader.UserAgent] = HttpUserAgent;
    }

    return webClient;
}

As you can see, caching is explicitly disabled using RequestCacheLevel.NoCacheNoStore.

Despite all this, the update still appears to be cached, and I don’t understand why.
When using ClickOnce, we never experienced this kind of issue, even though we’re using the same IIS server instance.

Could it be related to temporary files used during the download process?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions