Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

redirect from action inside controller?

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?

like image 930
John Avatar asked Mar 22 '23 13:03

John


2 Answers

You can use Redirect

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

return Redirect(url);
like image 177
D Stanley Avatar answered Apr 05 '23 05:04

D Stanley


Try this

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


 return RedirectToAction(url);
like image 32
Amit Avatar answered Apr 05 '23 07:04

Amit