操作链接在 MVC3 中不起作用
我在 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
你有这方面的路线吗?还要输入预期的 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?
如果您将鼠标悬停在该链接上,它会提供什么 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.