@ Url.Action("登录"," HECAccount")无法在cshtml中工作(布局)

时间:2014-11-19 04:48:33

标签: javascript jquery html asp.net-mvc-4 razor

我正在为我的asp.net mvc 4网络应用程序创建垂直菜单。

所以我提到this Link来整合我的事情。

所以我编辑了我的_HECLayout.cshtml(包含在“〜/ Views / Shared /”)文件中这样

   <!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>

它提供了像我提到的HERE演示的流畅视图,但是注销网址操作无法正常工作。所有网址都无法正常工作,

任何克服他的问题的建议

<li><a class="logout" href="@Url.Action("Login", "HECAccount")"><i class="icon-signout"></i>Logout</a></li>

1 个答案:

答案 0 :(得分:0)

当我尝试插入上面的jquery引用时,我得到了相同的错误,链接无法正常工作

所以我提到了This Link

这是一种给jquery引用HTML页面的方法,但是在插入@Scripts.Render("~/bundles/jquery")时在CSHTML中你不需要像在这里一样逐一添加引用,

删除<script type="text/javascript" src='~/Scripts/jquery-2.0.0.min.js'/></script>

@Scripts.Render("~/bundles/jquery")保留在代码

如果您的项目没有“ jquery-2.0.0.min.js ”文件,请手动插入“〜/ Script ”文件夹