views:

31

answers:

1

I'm trying to add a FAQ section to a website that I'm working on and I want to ignore any action or id that is added to the URL.

The RegisterRoutes method of the Global.asax.cs file has been changed to;

public static void RegisterRoutes(RouteCollection routes)
{
  routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

  routes.MapRoute(
      "FAQ",
      "FAQ",
      new {controller = "FAQ", action= "Index"});

    routes.MapRoute(
      "Default", // Route name
      "{controller}/{action}/{id}", // URL with parameters
      new { controller = "Home", action = "Index", id = UrlParameter.Optional } 
    );
}

The FAQController.cs looks like this;

public class FAQController : Controller
{
    private FAQModel _faq = new FAQModel();

    public ActionResult Index()
    {
        return View(_faq.GetFAQ());
    }
}

But this doesn't appear to be working, I was wondering whether anyone could point me in the right direction of how to do this.

Thanks for any help in advance

Satal :)

A: 

Try this:

routes.MapRoute(
    "FAQ", 
    "FAQ/{*pathInfo}", 
    new { controller = "FAQ", action = "Index" }
);
Steve Michelotti
Brilliant thanks, that was exactly what I needed :)
Satal