Tuesday, June 25, 2013

Redirect to HTML Page in ASP.NET MVC

Below code will set the default page of an ASP.NET MVC application to a HTML page.

Controller:

    public class HomeController : Controller
    {
        public ActionResult Index()
        {

            return Redirect("home.html");

        }
    }

Global.asax:

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

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

    }

No comments:
Write comments
Recommended Posts × +