public ActionResult Index(string path, int width, int height) { var code = ValidateCodeHelper.GetValidateCode(4); Session["vcode_" + path] = code.ToLower(); var image = ValidateCodeHelper.CreateValidateImage(code); var stream = new MemoryStream(); image.Save(stream, ImageFormat.Jpeg); image.Dispose(); stream.Position = 0; return(File(stream, "image/jpeg", "verifyCode.jpg")); }