0

We need to add a .html file which should be part of the root directory of our mvc app so i added the following

Route AnnouncementRoute = routes.MapPageRoute
                                      ("Announcement", "Announcement", "~/Announcement.html");

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

The above code makes all the default actionlinks to add Announcement

http://localhost/Announcement?action=actionname&controller=controllername

How to make sure my actionlinks generated does not contain Announcement in the link as follows which is correct?

http://localhost/?action=actionname&controller=controllername
Marcer
  • 839
  • 1
  • 12
  • 25

1 Answers1

0

You can use RouteCollection.IgnoreRoute(). Here's a good usage example that does exactly what you're trying to do.

jebar8
  • 2,113
  • 3
  • 21
  • 31
  • We don't want the file to be accessed as site.com/Announcement.html instead we want as site.com/Announcement – Marcer Jan 03 '14 at 00:42
  • Is there a reason you don't want to just create an Announcement controller with a single action and view with the contents of Announcement.html? – jebar8 Jan 03 '14 at 00:44