4

MVC - instead of creating a VM and passing in the values and drawing the view. i want to redirect to a URL using the values as parameters....so

instead of:

var model = new AvailabilityStepOneOfBookingVM(bookingQuery, 
                     ListOfBookings, chosenDate, foodPodId);

return View(model);

I want to load the URL:

http://localhost:40310/OrchardLocal/Food/FoodPodAvailability/
          StepOneOfBooking/(value of foodPodId)/(value of chosenDate)

redirect to action? directly from here or create a view and redirect from there?

4

3 回答 3

5

您可以使用Redirect

string url = string.Format("/OrchardLocal/Food/FoodPodAvailability" + 
                           "/StepOneOfBooking/{1}/{0}", chosenDate, foodPodId)

return Redirect(url);
于 2013-09-04T12:58:48.157 回答
1

如果你已经配置了你的路线,你可以这样做:

return RedirectToAction("ActionName", "ControllerName", new { foodPodId = 1,chosenDate = "2013-09-11" });
于 2013-09-11T17:15:23.397 回答
1

尝试这个

 string url = string.Format("/OrchardLocal/Food/FoodPodAvailability" + 
                       "/StepOneOfBooking/{1}/{0}", chosenDate, foodPodId)


 return RedirectToAction(url);
于 2013-09-05T11:54:11.067 回答