【问题标题】:RedirectToAction With String Parameters带字符串参数的 RedirectToAction
【发布时间】:2021-10-07 01:40:23
【问题描述】:

我想访问:例如用户/帐户/Alex 所以我所做的是-

return RedirectToAction("Account", "Users", new { userName= userName });

但是,我收到此错误: 找不到此本地主机页面 https://localhost:44351/Users/Account?userName=Alex

谁能告诉我我做错了什么? 谢谢!

【问题讨论】:

    标签: c# html model-view-controller


    【解决方案1】:

    试试这个

    return RedirectToAction("Account", "Users", new {id = userName });
    

    【讨论】:

    • 不客气!请不要忘记接受答案(单击答案侧的复选标记)
    • 你应该解释为什么“尝试这个”会有所帮助。您依赖于可选 {id} 路由参数的默认配置,OP 可能已将其重命名
    猜你喜欢
    • 1970-01-01
    • 2010-11-18
    • 2019-11-23
    • 1970-01-01
    • 1970-01-01
    • 2021-02-03
    • 2012-02-25
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多