tags:

views:

28

answers:

2

How to redirect a page to home page?

if (p == -1)
                return RedirectToAction("Index");

this opens webpage like http://abc.com/Index in url
i want just http://abc.com

A: 

Off the top of my head

return Redirect("~");
Stewart Ritchie
+3  A: 

You shoul have correct routing with default values in your Global.asax.cs file. For example

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

and after that

if (p == -1)
                return RedirectToAction("Index", "Home");
msi