Suppose I have controller which returns file (docx for example, but format doesn't matter, same behavior with jpg, png, etc)
[ApiController]
[Route("[controller]")]
public class FileController : Controller
{
[HttpGet("")]
public IActionResult Index()
{
var fileName = "File.docx";
var filePath = @$"C:\Sources\{fileName}";
FileStream stream = new FileStream(filePath, FileMode.Open, FileAccess.Read, FileShare.None);
return File(stream, "application/octet-stream", fileName);
}
}
If I use iOS Safari I get download dialog:
But in case of iOS Chrome, it opens content of the file and places it on the webpage:
In case of Chrome on Android tables, it works correctly:
Is it possible to fix this behavior for iOS Chrome somehow?
To understand the context of the problem: I place such a link on some web page. And when user clicks on it, iOS Chrome replaces this page with content of a file instead of downloading this file.
PS Btw, when I try the same but using some unknown binary file, iOS Chrome starts to work correctly: