前台验证码后台怎么获取啊
<img alt="验证码图片" name="image" id="SecurityCode" title="看不清,点击换一张" src ="<% =Url.Content("~/User/SecurityCode") %>"/>
这个是前台的验证码图片信息
[HttpPost]
public ActionResult Register(Users user, String SecurityCode, String image)
{
//怎么在这里获取验证码的值
if (ModelState.IsValid)
{
if (userManager.selUser(user))
{
ModelState.AddModelError("doubleUser", "当前用户已经被注册");
}
else
{
if (userManager.Register(user))
{
ViewBag.msg = "注册成功";
return View("RegisterResult");
}
else
{
ViewBag.msg = "注册失败";
}
}
}
return View();
}
public ActionResult SecurityCode( ) {
String oldcode = TempData["Securitycode"] as String;
code = CreateRandomCode(5);
TempData["Securitycode"] = code;
ViewData["data"] = code;
return File(CreateValidateGraphic(code), "image/Jpeg");
}
private String CreateRandomCode(int codeCount) {
String allChar = "0,1,2,3,4,5,6,7,8,9,,Q,W,E,R,T,Y,U,I,O,P,A,S,D,F,G,H,J,K,L,Z,X,C,V,B,N,M";
String[] allCharArray = allChar.Split(',');
String randomCode = "";
int temp = -1;
Random rand = new Random();
for (int i = 0; i < codeCount;i++ ) {
if(temp!=-1){
rand = new Random(i * temp * ((int)DateTime.Now.Ticks));
}
int t = rand.Next(35);
if(temp == t){
return CreateRandomCode(codeCount);
}
temp = t;
randomCode += allCharArray[t];
}
return randomCode;
}
public byte[] CreateValidateGraphic(String vaildateCode) {
Bitmap image = new Bitmap((int)Math.Ceiling(vaildateCode.Length * 16.0), 27);
Graphics g = Graphics.FromImage(image);
try
{
Random random = new Random();
g.Clear(Color.White);
for (int i = 0; i < 25; i++)
{
int x1 = random.Next(image.Width);
int x2 = random.Next(image.Width);
int y1 = random.Next(image.Height);
int y2 = random.Next(image.Height);
g.DrawLine(new Pen(Color.Silver), x1, x2, y1, y2);
}
Font font = new Font("Arial", 13, (FontStyle.Bold | FontStyle.Italic));
LinearGradientBrush brush = new LinearGradientBrush(
new Rectangle(0, 0, image.Width, image.Height),
Color.Blue, Color.DarkRed, 1.2f, true);
g.DrawString(vaildateCode, font, brush, 3, 2);
for (int i = 0; i < 100; i++)
{
int x = random.Next(image.Width);
int y = random.Next(image.Height);
image.SetPixel(x, y, Color.FromArgb(random.Next()));
}
g.DrawRectangle(new Pen(Color.Silver), 0, 0, image.Width - 1, image.Height - 1);
MemoryStream stream = new MemoryStream();
image.Save(stream, ImageFormat.Jpeg);
return stream.ToArray();
}
finally {
g.Dispose();
image.Dispose();
}
}
}
}
求大神解答