-1

我有一个控制器:

    public ActionResult Index(string id)
    {
        ViewBag.ReloadedFromEmailForm = id;

        return View();
    }

可以使用参数从 RouteConfig(作为其默认值)id = null调用控制器,并且可以从返回的其他控制器调用

return RedirectToAction("Index", "Home", new {id = 1});

现在我想得到它,id = 1但是当我打开应用程序时在我的 url 中设置,就像没有任何参数的常规一样。

如何做到这一点?

现在:localhost:8888/Index/1

我想要什么:(localhost:8888/Index/但我仍然想填写 ViewBag)。

4

1 回答 1

0

解决了。我没有意识到该属性名称id已经在路由配置中,并自动映射到 url。我需要做的就是将我的道具更改为其他任何东西,例如 foobar :)

于 2019-11-17T12:52:21.620 回答