1

I have hotels list, and each of hotel has his details page, I need to navigate on that pages with fallowing URLs

/Hotel/HotelName

where Hotel my controller and HotelName is parameter for his index action

public ActionResult Index(string hotelName)

In ASP.NET MVC how can I config my routing for reach this result? Thanks.

1 Answer 1

2

Add this route before default route:

routes.MapRoute(
    name: "Hotels",
    url: "Hotel/{hotelName}",
    defaults: new { controller = "Hotel", 
                    action = "Index", 
                    hotelName = UrlParameter.Optional }
);
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.