0
这里是我当前的代码,我用这来实现标签如何从控制器上下文返回的ActionResult的另一个动作
public ActionResult Index(string tabs, int id = 0)
{
switch ((Tabs)Enum.Parse(typeof(Tabs), tabs,true))
{
case Tabs.Profile:
default:
return Profile(id);
}
}
public ActionResult Profile(int id = 0)
{
User user = UsersRepository.GetUser(id);
if (user!= null)
{
return View(user);
}
return Redirect("/");
}
我不想使用RedirectToAction
因为这将改变的URL结构是什么我想了。事情是这样的:
http://localhost/user?tabs=profile
http://localhost/user?tabs=settings