Вопрос по asp.net-mvc-3 – отправлять данные между действиями с помощью redirectAction и шаблона prg

4

Error: User Rate Limit Exceeded

Error: User Rate Limit Exceeded

[HttpGet]
    [ActionName("Success")]
    public ActionResult Success(PersonalDataViewModel model)
    {
        //model ko
        if (model == null)
            return RedirectToAction("Index", "Account");

        //model OK
        return View(model);
    }

    [HttpPost]
    [ExportModelStateToTempData]
    [ActionName("Success")]
    public ActionResult SuccessProcess(PersonalDataViewModel model)
    {

        if (!ModelState.IsValid)
        {
            ModelState.AddModelError("", "Error");
            return RedirectToAction("Index", "Account");
        }

        //model OK
        return RedirectToAction("Success", new PersonalDataViewModel() { BadgeData = this.GetBadgeData });
    }
Error: User Rate Limit ExceededBadgeDataError: User Rate Limit ExceededBadgeData = model.GetBadgeDataError: User Rate Limit Exceededthis? mattytommo
Error: User Rate Limit Exceeded Jason Evans

Ваш Ответ

3   ответа
0

HTTP 302GET

[HttpPost]
public ActionResult SuccessProcess(PersonViewModel model)
{
  //Some thing is Posted (P) 
  if(ModelState.IsValid)
  {
    //Save the data and Redirect (R)
    return RedirectToAction("Index",new { id=model.ID});
  }
  return View(model)
}

public ActionResult Index(int id)
{
  //Lets do a GET (G) request like browser requesting for any time with ID
  PersonViewModel model=GetPersonFromID(id);
  return View(id);
}

}

PRG

Error: User Rate Limit Exceeded Pedre
Error: User Rate Limit Exceeded
Error: User Rate Limit Exceeded
Error: User Rate Limit Exceededlink Pedre
Error: User Rate Limit Exceeded Pedre
9

return RedirectToAction("Success", new {
    prop1 = model.Prop1,
    prop2 = model.Prop2,
    ...
});

int id = StoreModel(model);
return RedirectToAction("Success", new { id = id });

public ActionResult Success(int id)
{
    var model = GetModel(id);
    ...
}

TempData

TempData["model"] = model;
return RedirectToAction("Success");

SuccessTempData:

var model = TempData["model"] as PersonalDataViewModel;
Error: User Rate Limit ExceededTempData?
Error: User Rate Limit Exceeded Pedre
Error: User Rate Limit Exceeded
Error: User Rate Limit Exceeded
2

[HttpGet]
public ActionResult Success(int? id)
{
    if (!(id.HasValue))
        return RedirectToAction("Index", "Account");

    //id OK
    model = LoadModelById(id.Value);
    return View(model);
}

idRedirectToAction

    return RedirectToAction("Success", { id = Model.Id });
Error: User Rate Limit Exceeded Pedre

Похожие вопросы