在登录链接上重新访问鼠标

本文关键字:访问 鼠标 新访问 登录 链接 | 更新日期: 2023-09-27 18:25:03

我将其保留在站点的默认css文件中

.hover  a
{
    background-color:Gray;
    text-decoration:none;
}
.hover  a:hover
{
    background-color:Red;
    color:White;
}

和在_LogonPartial.chtml 中

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

只有类hover->a是有效的,我也很奇怪,为什么当我的鼠标在登录链接上时,URL会添加"?length=7",那是什么?

在登录链接上重新访问鼠标

待完成。

CSS

a.hover:hover 替换.hover a:hover

?长度问题

此链接解释了发生这种情况的原因:为什么Html.ActionLink渲染"?Length=4"

根据链接的帖子,将ActionLink更改为以下内容应该可以解决这个问题。

Html.ActionLink("Log On", "LogOn", new { controller = "Account" }, new { @class = "hover" })

或者,如果你已经来自帐户控制器,那么你不需要在链接中再次指定它,null也可以。null使链接指向视图开始时所在的控制器中的操作。

Html.ActionLink("Log On", "LogOn", null, new { @class = "hover" })

很明显,您使用了ActionLink的错误覆盖。

您的css应该是:

a.hover
{
    background-color:Gray;
    text-decoration:none;
}
a.hover:hover
{
    background-color:Red;
    color:White;
}