0
改變這是我的路線:網址自動
routes.MapRoute(
"LastTwoRoute",
"thong-ke-ket-qua-xo-so-2-so-cuoi/{cityID}/{numbers}/{days}/{onlySpecial}",
new { controller = "LastTwo", action = "Index",
cityID = "MB",
numbers = "",
days = 1000,
onlySpecial = false
});
這是控制器:
[HttpGet]
public ActionResult Index(string cityID, string numbers, int days, bool onlySpecial)
{
LastTwoParameters lastTwoParameters = new LastTwoParameters();
lastTwoParameters.listCities = Common.GetDropDownCitiesList();
lastTwoParameters.listLastTwoResult = new List<getReport_LastTwo_Result>();
if (TempData["Redirection"] != null || !string.IsNullOrEmpty(numbers))
{
if (!string.IsNullOrEmpty(cityID) && days > 0)
{
using (KQXS context = new KQXS())
{
lastTwoParameters.listLastTwoResult = context.getReport_LastTwo(cityID, numbers, days, onlySpecial).ToList();
}
}
}
return View(lastTwoParameters);
}
[HttpPost]//Run action method on form submission
public ActionResult Index(List<Cities> c, string cityID, string numbers, int days, bool onlySpecial)
{
TempData["Redirection"] = true;
return RedirectToAction("Index", new { cityID = cityID, numbers = numbers, days = days, onlySpecial = onlySpecial });
}
當我第一次訪問控制,URL是:
http://example.com/thong-ke-ket-qua-xo-so-2-so-cuoi
當我從參數面板中選擇任意參數並點擊提交:
http://example.com/LastTwo?cityID=NBD&numbers=&days=70&onlySpecial=False
的thong-ke-ket-qua-xo-so-2-so-cuoi
部分被替代爲控制器名稱:LastTwo
參數部成爲?para=value
這究竟是爲什麼
http://example.com/thong-ke-ket-qua-xo-so-2-so-cuoi/MB/5/70/True
但由於種種原因,有時網址submiting後成爲該如何防止這種情況?謝謝!
完美!非常感謝! – NeedAnswers 2014-11-06 05:03:24
歡迎你的朋友! – 2014-11-06 05:12:06