//显示验证码 public ActionResult SecurityCode() { string oldcode = TempData["SecurityCode"] as string; string code = JsHelper.CreateRandomCode(4); //验证码的字符为4个 TempData["SecurityCode"] = code; //验证码存放在TempData中 return(File(JsHelper.CreateValidateGraphic(code), "image/Jpeg")); }