MVC - 而不是创建VM并传入值并绘制视图。我想使用值作为参数重定向到URL ....所以
而不是:
var model = new AvailabilityStepOneOfBookingVM(bookingQuery,
ListOfBookings, chosenDate, foodPodId);
return View(model);
我想加载网址:
http://localhost:40310/OrchardLocal/Food/FoodPodAvailability/
StepOneOfBooking/(value of foodPodId)/(value of chosenDate)
重定向到行动?直接从这里或创建一个视图并从那里重定向?
答案 0 :(得分:5)
您可以使用Redirect
string url = string.Format("/OrchardLocal/Food/FoodPodAvailability" +
"/StepOneOfBooking/{1}/{0}", chosenDate, foodPodId)
return Redirect(url);
答案 1 :(得分:1)
试试这个
string url = string.Format("/OrchardLocal/Food/FoodPodAvailability" +
"/StepOneOfBooking/{1}/{0}", chosenDate, foodPodId)
return RedirectToAction(url);
答案 2 :(得分:1)
如果您已配置路线,可以这样做:
return RedirectToAction("ActionName", "ControllerName", new { foodPodId = 1,chosenDate = "2013-09-11" });