开发者

how to RedirectToAction to home page?

How to red开发者_如何学编程irect 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


Off the top of my head

return Redirect("~");


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");
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜