As a specific example within my application, I would like to have the information of the room (which is a combination of hotel name and room name) at http://mybooking.com/{hotelName}/{roomNr}
passed onto my reservation controller at http://mybooking.com/reservation
, and I really wonder what would be the best practice for doing it.
To be more specific, within the Room
page (at http://mybooking.com/{hotelName}/{roomNr}
), when user clicks on a button called "Book this room", he/she will be redirected to Reservation
page. Thus, I want to know the most appropriate way to preserve the hotelName
and roomNr
from Room
page to Reservation
page.
I tried passing it through the URL like http://mybooking.com/reservation/{hotelName}/{roomNr}
, but I believe this isn't the best solution, since I can only then access to the hotelName and roomNr in the specific index method of this controller:
//ReservationController
[HttpGet("/Reservation/{hotelName}/{roomNr}")]
public IActionResult Index(string hotelName, int roomNr)
{
//hotelName and roomNr can only be accessed here
}
I do need this piece of information for other methods within the controller or the service as well, and I wonder if it is applicable with the current implementation.
Any suggestion on this case?