布局文件未加载和路由问题MVC?

时间:2017-08-09 11:21:39

标签: asp.net-mvc asp.net-mvc-4 routing

我的路线配置文件是

 routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

        routes.MapRoute(
            name: "Default",
            url: "{controller}/{action}/{id}",
            defaults: new { controller = "Login", action = "Login", id = UrlParameter.Optional }
        );

默认登录是加载登录控制器

 [Route("")]
    public ActionResult Login()
    {
        ViewBag.CustomerId = 0;
        ViewBag.Country = "pak";
        ViewBag.Email = "nouman@softconsults.com";
        return View();
    }

url默认加载布局页面,设计正确http://localhost:2738/ 但是当点击登录提交按钮或由网址调用时,与网址相同的视图 http://localhost:2738/Login/Login似乎未正确加载,请参阅图片了解详情

issue image

与其他文件类似的问题我的主布局页面没有加载但是在登录时点击我的网址添加登录并继续添加错误的用户密码但正确的用户密码工作成功完全和下一页只是不加载其主人在这里网址成为万一用户密码错误,继续添加登录

http://localhost:2738/Login/Login/Login/Login

顶部的CSS引用

  <link rel="stylesheet" href="@Url.Content("Website/CSS/supersized.css")" type="text/css" media="screen " />
<link href="@Url.Content("http://fonts.googleapis.com/css?family=Oxygen:400,300,700")" rel='stylesheet'  type='text/css'>

<link href="@Url.Content("Website/CSS/custom.css.css")" rel="stylesheet" type="text/css"/>

<script type="text/javascript" src="@Url.Content("https://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js")"></script>

<script type="text/javascript" src="@Url.Content("Website/JS/jquery.easing.min.js")"></script>

<script type="text/javascript" src="@Url.Content("Website/JS/supersized.3.2.7.js")"></script>


<script type="text/javascript">

    jQuery(function ($) {

        $.supersized({

            // Functionality
            slide_interval: 3000,       // Length between transitions
            transition: 3,          // 0-None, 1-Fade, 2-Slide Top, 3-Slide Right, 4-Slide Bottom, 5-Slide Left, 6-Carousel Right, 7-Carousel Left
            transition_speed: 700,      // Speed of transition

            // Components
            slide_links: 'blank',   // Individual links for each slide (Options: false, 'num', 'name', 'blank')
            slides: [           // Slideshow Images
                                                { image: 'Website/Main/banner_1.png', },
                                                { image: 'Website/Main/banner_2.png', },
                                                { image: 'Website/Main/banner_3.png', },
                                                { image: 'Website/Main/banner_4.png', },
                                                { image: 'Website/Main/banner_5.png', },
                                                { image: 'Website/Main/banner_6.png', },
                                                { image: 'Website/Main/banner_7.png', },
                                                { image: 'Website/Main/banner_8.png', }

            ]

        });
    });

</script>

在页面底部登录和主页索引视图

    <script src="@Url.Content("~/Scripts/jquery.unobtrusive-ajax.js")"></script>
<script  src="@Url.Content("~/Scripts/jquery.unobtrusive-ajax.js")"></script>
 <script src="@Url.Content("~/Scripts/jquery.validate-vsdoc.js")"></script>
 <script  src="@Url.Content("~/Scripts/jquery.validate.min.js")"></script>
 <script src="@Url.Content("~/Scripts/jquery.validate.js")"></script>
 <script  src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.js")"></script>
 <script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")"></script>
 <script  src="@Url.Content("~/Scripts/jquery.unobtrusive-ajax.min.js")"></script>

1 个答案:

答案 0 :(得分:0)

尝试使用以下方法,而不是使用直接相对路径。

<link href="@Url.Content("~/Website/CSS/supersized.css")" rel="stylesheet" type="text/css" />

您也可以将此方法用于CSS,JS,图像。