首页 > 解决方案 > 为什么不在 ie 11 和 Firefox 中“将图像另存为”调用操作方法?

问题描述

我的cshtml代码:

<img id="imgCapImage" alt="Captcha" src="@Url.Action("RefreshCaptcha", "Account")" />

我的操作代码:

[HttpGet]
[AllowAnonymous]
public FileContentResult RefreshCaptcha(string id)
{
    FileContentResult img = null;
        try
        {
            string rndCode = "";
            byte[] fileContentResult = VerificationTextGenerator(ref rndCode);
            Session["RandomCode"] = rndCode;
            img = new FileContentResult(fileContentResult, "image/gif");
        }
        catch (Exception)
        {}
        return img;
}

chrome上一切正常。当我单击“将图像另存为”时,它会调用操作方法,并且由于安全问题,我会刷新验证码以防止第 3 方库解析验证码。但是如果我在ie和firefox中做同样的事情,它不会调用action方法并直接下载图像吗?可能吗?我用谷歌搜索了它,但没有找到。

标签: imageinternet-explorerfirefoxmodel-view-controllercaptcha

解决方案


推荐阅读