操作链接在 MVC3 中不起作用

发布于 2024-11-08 21:02:16 字数 899 浏览 6 评论 0原文

我在 View>Shared 文件夹中创建了一个视图,

其中包含此代码

@if (Request.IsAuthenticated)
{
    <text>Welcome <strong>@User.Identity.Name</strong>!
    @Html.ActionLink("Log Off", "LogOff", "Account", new { data_role = "button" })</text>
}
else
{
    @Html.ActionLink("Log On", "LogOn", "Account", new { data_role = "button" })

}

我在控制器文件夹中创建了一个控制器

 public class AccountController : Controller
    {
        //
        // GET: /Account/

        public ActionResult Index()
        {
            return View();
        }

        public ActionResult LogOn()
        {
            return View();
        }

        public ActionResult LogOff()
        {
            return View();
        }

    }

,然后右键单击 Index logOn 和 LogOff 视图在该文件夹中创建 浏览次数>帐户

但是当我单击“登录”按钮时,我没有重定向到登录页面。

请帮忙

I have created a view in View>Shared folder

Which has this code

@if (Request.IsAuthenticated)
{
    <text>Welcome <strong>@User.Identity.Name</strong>!
    @Html.ActionLink("Log Off", "LogOff", "Account", new { data_role = "button" })</text>
}
else
{
    @Html.ActionLink("Log On", "LogOn", "Account", new { data_role = "button" })

}

Than I have created a controller in the controller folder

 public class AccountController : Controller
    {
        //
        // GET: /Account/

        public ActionResult Index()
        {
            return View();
        }

        public ActionResult LogOn()
        {
            return View();
        }

        public ActionResult LogOff()
        {
            return View();
        }

    }

and by right click on the Index logOn and LogOff views are created in the folder
Views> Account

But when I am clicking on the Log On button I am not redirecting to the logOn page.

Please help

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

此刻的回忆 2024-11-15 21:02:16

你有这方面的路线吗?还要输入预期的 URL,看看是否可以访问它。当您将鼠标悬停在链接上时,它是否显示正确的网址?

Do you have a route for this? Also type in the expected URL and see if you can get to it. Does it show the right url when you mouse over the link?

断念 2024-11-15 21:02:16

如果您将鼠标悬停在该链接上,它会提供什么 URL?您可能正在解决 ActionLink 的错误重载问题。我以前也遇到过这种情况。在 ActionLink 调用中添加一个额外的 null 参数,它应该解析为正确的参数。

If you hover over the link, what URL does it give you? It may be that you are resolving to the wrong overload of ActionLink. I've had this happen before as well. Add an extra null parameter in your ActionLink call and it should resolve to the correct one.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文