HomeController.cs 849 B

12345678910111213141516171819202122232425262728293031323334
  1. using PersonalBlog.App_Code;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Drawing;
  5. using System.Linq;
  6. using System.Web;
  7. using System.Web.Mvc;
  8. namespace PersonalBlog.Controllers
  9. {
  10. public class HomeController : Controller
  11. {
  12. // GET: Home
  13. public ActionResult Index()
  14. {
  15. return View();
  16. }
  17. public ActionResult Blog()
  18. {
  19. return View();
  20. }
  21. public FileResult ValidCode()
  22. {
  23. ValidateCode __validateCode = new ValidateCode();
  24. string code = __validateCode.CreateVerifyCode();
  25. Session["validateCode"] = code;
  26. Bitmap __bm = __validateCode.CreateImageCode(code);
  27. byte[] bytes = Tools.ConvertHelper.BitmapToBytes(__bm);
  28. return File(bytes, @"image/Jpeg");
  29. }
  30. }
  31. }