@Url.Action(“Login”, “HECAccount”) 在 cshtml(layout)中不起作用
@Url.Action("Login", "HECAccount") not working in cshtml (layout)
我正在为我的 asp.net mvc 4 Web应用程序创建垂直菜单。
所以我提到了这个链接来整合到我的事情中.
所以我编辑了我的 _HECLayout.cshtml(包含在"~/视图/共享/")文件中,就像这样
<!DOCTYPE html>
<html lang="en">
<head>
<script type="text/javascript" src='~/Scripts/jquery-2.0.0.min.js'/></script>
<link href="~/Content/font-awesome.min.css" rel="stylesheet" />
<link href="~/Content/font-awesome.css" rel="stylesheet" />
<link href="~/Content/css.css" rel="stylesheet" />
<script>
$(document).ready(function () {
$('ul.formxd li a').click(
function (e) {
e.preventDefault(); // prevent the default action
e.stopPropagation; // stop the click from bubbling
e.stopPropagation; // stop the click from bubbling
$(this).closest('ul').find('.selected').removeClass('selected');
$(this).parent().addClass('selected');
});
});
</script>
<meta charset="utf-8" />
<title>@ViewBag.Title - Higher Education Council</title>
<link href="~/favicon.ico" rel="shortcut icon" type="image/x-icon" />
<meta name="viewport" content="width=device-width" />
@Styles.Render("~/Content/css")
@Scripts.Render("~/bundles/modernizr")
<div id="header">
<div id="top-area">
<div id="logo-area">
<img src="~/Images/hec-logo.png" />
</div>
</head>
<body>
<header>
<div class="content-wrapper">
<div class="float-right">
<section id="text-view" style="display: inline; width: 100%; text-align: right;" >
<p><i>Higher Education Institutes </i></p>
</section>
</div>
</div>
</header>
@RenderSection("featured", required: false)
<div id="menu_area">
<div class="hec_admin_menu" >
<ul class="formxd">
<li class="welcome"><a class="welcome"><i class="icon-fa-university"></i>Welcome HEC</a></li>
<li ><a class="dashboard" href="#"><i class="icon-dashboard"></i>Dashboard</a></li>
<li ><a class="reports" href="#"><i class="icon-file"></i>Reports</a></li>
<li><a class="administrator" href="#"><i class="icon-user"></i>Administrator</a></li>
<li><a class="search" href="#"><i class="icon-search"></i>Search</a></li>
<li><a class="logout" href="@Url.Action("Login", "HECAccount")"><i class="icon-signout"></i>Logout</a></li>
</ul>
</div>
<div class="hec_admin_body">
<section class="content-wrapper main-content clear-fix">
@RenderBody()
</section>
</div>
</div>
<footer>
</footer>
@Scripts.Render("~/bundles/jquery")
@RenderSection("scripts", required: false)
</body>
</html>
它提供了流畅的视图,就像我在这里提到的演示一样,但注销网址操作无法正常工作。并且所有网址都无法正常工作,
任何建议要克服他的麻烦
<li><a class="logout" href="@Url.Action("Login", "HECAccount")"><i class="icon-signout"></i>Logout</a></li>
当我
尝试像上面这样插入jquery引用时,我遇到了同样的错误,链接不起作用
所以我提到了这个链接
这是一种给 jquery 引用 HTML 页面的方法,但在 CSHTML 中,当你插入@Scripts.Render("~/bundles/jquery")
时,你不需要像这里那样逐个添加引用,
所以删除<script type="text/javascript" src='~/Scripts/jquery-2.0.0.min.js'/></script>
将@Scripts.Render("~/bundles/jquery")
保持在代码下
如果您的项目没有"jquery-2.0.0.min.js"文件,请手动插入到"~/脚本"文件夹中
相关文章:
- 将对象传递到sails.js中的views/layout.ejs
- 在cshtml中对特殊字符进行编码
- 如何使用d3.layout.cloud.js创建一个包含单词及其权重的csv的单词云
- jslint and cshtml files
- 定义 Backbone.Layout 作为 need js 模块
- 为什么我的 cshtml 页面的 javascript 没有在浏览器中更新/刷新
- $('body').layout 不是一个函数
- CSHTML 中 JavaScript 上的断点
- D3.js:通过Force Layout从JSON文件加载多个网络
- Ember.js Layout
- 如何在layout.ejs上获取节点
- 我应该如何从javascript/jquery调用cshtml文件
- MVC视图文件_Layout.cshtml中头部和主体的Render Bundles之间的差异
- 布局lt md已被弃用.请使用`layout gt-<xxx>`变种
- 如何自动确定d3.layout.tree大小
- 根据列值将类添加到元素中;使用WebMatrix sql数据库、Cshtml(Razor)和JavaScript
- d3.layout.tree中的颜色路径
- C# 在 中嵌入资源.Js 文件而不是 .cshtml
- Layout.cshtml 中的 Intellisense for js 和 css 不起作用
- @Url.Action(“Login”, “HECAccount”) 在 cshtml(layout)中不起作用