How to Override the Common Route Prefix? | ASP.Net MVC Interview Question

, ,
  • You can use a tilde (~) on the method attribute to override the route prefix
  • Well,It's like this : [Route("~/PetBooking")]
       
        BookingController.cs

    [RoutePrefix("Booking")]
    public class BookingController : Controller
    {
        // eg: /PetBooking
        [Route("~/PetBooking")]
        public ActionResult PetBooking() { return View(); }
    }

Above Route on Browser is as below