Wily_Fox
چهارشنبه 04 اردیبهشت 1392, 17:51 عصر
با سلام و خسته نباشید
داخل یکی از Action های page تولید کد امنیتی رو قرار دادم.
هنگامی این Action رو فراخونی می کنم خود به خود 2 بار فراخونی میشه و باعث میشه هربار دو تا کد تولید بشه.
مشکل از چی میتونه باشه.
تابع ایجاد کد:
private string CreateSecurityImage()
{
try
{
SecurityCode securityCode = new SecurityCode();
string FileName = null;
Image img = securityCode.GetNewSecurityCode(ref FileName);
string path = Server.MapPath("~/Content/image/Security/" + FileName + ".jpg");
img.Save(path, ImageFormat.Jpeg);
return FileName;
}
catch { return null; }
}
اکشن مورد نظر:
public ActionResult Content(int id)
{
if (ModelState.IsValid)
{
if (id > 10)
{
try
{
var securityCode = new SecurityCodeModel
{
Text = CreateSecurityImage(),
Value=null
};
...
return View(model);
}
catch { }
}
}
return RedirectToAction("Index", "Home");
}
فراخونی یعنی اینکه تو Url مرورگر، آدرس page رو قرار بدم و Enter بزنم 2 تا کد تولید میکنه.
بدون هیچ خطایی دو بار این عمل اتفاق می افته.
مثل اینکه دو بار refresh کرده باشی
داخل یکی از Action های page تولید کد امنیتی رو قرار دادم.
هنگامی این Action رو فراخونی می کنم خود به خود 2 بار فراخونی میشه و باعث میشه هربار دو تا کد تولید بشه.
مشکل از چی میتونه باشه.
تابع ایجاد کد:
private string CreateSecurityImage()
{
try
{
SecurityCode securityCode = new SecurityCode();
string FileName = null;
Image img = securityCode.GetNewSecurityCode(ref FileName);
string path = Server.MapPath("~/Content/image/Security/" + FileName + ".jpg");
img.Save(path, ImageFormat.Jpeg);
return FileName;
}
catch { return null; }
}
اکشن مورد نظر:
public ActionResult Content(int id)
{
if (ModelState.IsValid)
{
if (id > 10)
{
try
{
var securityCode = new SecurityCodeModel
{
Text = CreateSecurityImage(),
Value=null
};
...
return View(model);
}
catch { }
}
}
return RedirectToAction("Index", "Home");
}
فراخونی یعنی اینکه تو Url مرورگر، آدرس page رو قرار بدم و Enter بزنم 2 تا کد تولید میکنه.
بدون هیچ خطایی دو بار این عمل اتفاق می افته.
مثل اینکه دو بار refresh کرده باشی