2013-04-01 30 views
0

我周五离开了,我的应用程序在开发模式下工作....我今天早上进来,Layout.Mobile.chtml没有被使用。 ....这是开发模式,所以我仍然每次启动Web服务器....我阅读了有关缓存的类似问题....但我不明白这可能与我的问题有关,因为一旦Web服务器关闭,高速缓存被清除。Layout.mobile.cshtml突然停止工作 - 不应该与缓存相关

我使用Visual Studio 2012作为我的开发“Web服务器”。

一切都在运行,我看不出问题出在哪里,也不理解下一步要看的地方。任何建议如何诊断这个问题或在哪里看,将不胜感激。

这是只为Layout.Mobile.cshtml ....当我切换回Layout.cshtml它被称为精细....

在我的global.asax.cs我有下面设置为强制火狐使用移动布局来显示:

//The following forces Firefox to use the Mobile View ONLY 
    DisplayModeProvider.Instance.Modes.Insert(0, new DefaultDisplayMode("mobile") 
    { 
     ContextCondition = (context => 
      context.Request.UserAgent.IndexOf("Mozilla", StringComparison.OrdinalIgnoreCase) >= 0) 
    }); 

我_ViewStart.cshtml文件是:

@{ 
    Layout = "~/Views/Shared/_Layout.cshtml"; 
} 

我_Layout.Cshtml是:

<!DOCTYPE html> 
<html lang="en"> 
    <head> 
     <meta charset="utf-8" /> 
     <title>@ViewBag.Title - Etracs</title> 
     <link href="~/favicon.ico" rel="shortcut icon" type="image/x-icon" /> 
     <meta name="viewport" content="width=device-width" /> 

     @Styles.Render("~/Content/css")  

<script src="~/Scripts/jquery-1.9.1.js"></script> 
     <script src="~/Scripts/jquery-migrate-1.1.1.js"></script> 

     @RenderSection("scripts", required: false) 
    </head> 
    <body> 


     <header> 
      *@ 
     </header> 

     <div id="body">   
      <section class="content-wrapper main-content clear-fix"> 
       @RenderBody() 
      </section> 
     </div> 


     @Html.Partial("_ViewSwitcher") 
     <footer> 
      <div class="content-wrapper"> 
       <div class="float-left"> 
        <p>&copy; @DateTime.Now.Year - Turning Basin Services</p> 
       </div> 
      </div> 
     </footer> 

    </body> 
</html> 

我_Layout.Mobile.cshtml是:

<!DOCTYPE html> 
<html> 
    <head> 
     <meta charset="utf-8" /> 
     <title>@ViewBag.Title</title> 
     <meta name="viewport" content="width=device-width, initial-scale=1" /> 

     @* @Styles.Render("~/Content/Mobile/css") *@ 
     @* @Styles.Render("~/Content/jquerymobile/css") *@ 
     <link rel="stylesheet" href="~/Content/Mobile/css/jquery.mobile-1.2.0.css" /> 
     <link rel="stylesheet" href="~/Content/Mobile/css/jquery.mobile.theme-1.2.0.css" /> 

     @* @Scripts.Render("~/bundles/jquery") *@ 
     @* @Scripts.Render("~/bundles/jquerymobile") *@ 
     <script src="~/Scripts/jquery-1.9.1.js"></script> 
     <script src="~/Scripts/jquery-migrate-1.1.1.js"></script> 
     <script src="~/Scripts/jquery.mobile-1.2.0.js"></script> 

     <script> 
      $(document).ready(function() { 
       $.mobile.ajaxEnabled = false; 
      }); 
     </script> 

     @RenderSection("scripts", required: false) 
    </head> 

    <body> 

     <div data-role="page" data-theme="c"> 

      <div data-role="header"> 
       @RenderSection("backbtn", false)  
       <h1>@ViewBag.Title</h1> 
       @RenderSection("Home", false) 
      </div> 

      <div data-role="content"> 
       @*  @RenderSection("featured", false) *@ 
        @RenderBody()  
      </div> 

      <div data-role="footer"> 
        <h4> @Html.Partial("_ViewSwitcher") &copy; @DateTime.Now.Year - Turning Basin Services</h4> 
      </div> 
     </div> 

    </body> 
</html> 

在我的意见,我通常使用viewstart建立以impliclity地图布局....但是,我.Login.Mobile .cshtml硬线assocaiation到移动布局如下:

@model TBS.Etracs.Web.Main.Models.LoginModel 

@{ 
    ViewBag.Title = "Log in"; 
    Layout = "~/Views/Shared/_Layout.Mobile.cshtml"; 
} 



    @Html.ValidationSummary(true) 
<section id="loginForm"> 
    @* @using (Html.BeginForm(new { ReturnUrl = ViewBag.ReturnUrl })) { *@ 
    @using (Html.BeginForm ("Login")) { 
    @Html.AntiForgeryToken() 


     <div data-role="content"> 
      <div data-role="fieldcontain"> 
       <label for="UserName">UserName:</label> 
       @Html.TextBoxFor(m => m.UserName) 
       @Html.ValidationMessageFor(m => m.UserName) 
      </div> 

      <div data-role="fieldcontain"> 
       <label for="Password">Password</label> 
       @Html.PasswordFor(m => m.Password) 
       @Html.ValidationMessageFor(m => m.Password) 
      </div> 


      <div data-role="fieldcontain"> 
       <label for="ProgramMode">ProgramMode</label> 
       <select name="ProgramMode" id="ProgramMode"> 
        <option value="VW">VW</option> 
        <option value="Porsche">Porsche</option> 
        <option value="Bentley">Bentley</option> 
       </select> 
      </div> 

     <div data-role="fieldcontain"> 
       <label for="ConnectionMode">ConnectionMode</label> 
       <select name="ConnectionMode" id="ConnectionMode"> 
        <option value="Production">Production</option> 
        <option value="Test">Test</option> 
       </select> 
      </div> 


      <input type="submit" value="Log in" /> 

     </div> 

    } 
</section> 


@section Scripts { 
    @Scripts.Render("~/bundles/jqueryval") 
} 
+0

我刚刚确认我有FixedDisplayModes nuge t包安装.... – user2040849

回答

0

使用一瞥,我发现了_layout.mobile.cshtml仍然被打了个包括....的问题是,它不能正常工作。 ......涉及到我以前的问题.....

在我_Layout.Mobile.chtml我又回到了下面的代码和我的布局,现在正

<link rel="stylesheet" href="~/Content/Mobile/css/jquery.mobile-1.2.0.css" /> 
    <link rel="stylesheet" href="~/Content/Mobile/css/jquery.mobile.theme-1.2.0.css" /> 

    <script src="~/Scripts/jquery-1.9.1.js"></script> 
    <script src="~/Scripts/jquery-migrate-1.1.1.js"></script> 
    <script src="http://code.jquery.com/mobile/latest/jquery.mobile.min.js"></script> 

我用它来取代我的_layout.Mobile.cshtml以下行

<link rel="stylesheet" href="~/Content/Mobile/css/jquery.mobile-1.2.0.css" /> 
<link rel="stylesheet" href="~/Content/Mobile/css/jquery.mobile.theme-1.2.0.css" /> 


<script src="~/Scripts/jquery-1.9.1.js"></script> 
<script src="~/Scripts/jquery-migrate-1.1.1.js"></script> 
<script src="~/Scripts/jquery.mobile-1.2.0.js"></script> 

我非常困惑的一个大问题就是发生了什么......这个前牙工作了几天,然后退出工作.....输入将不胜感激。

0

我看到您承认您并不认为这与缓存有关 - 但我在此添加此项,因为使用移动视图时需要注意这一点至关重要。

缓存错误在这里解释

戴夫·沃德:

的东西每个人都应该知道使用MVC 4的移动视图 支持的时候是有一个在RTM版本导致的错误 第一次在视图中出现分辨率缓存的视图 后,为移动设备呈现错误视图。棘手的部分是, 不会在调试模式或直到在 发布模式中处于非活动状态15分钟才会注意到,所以很容易让buggy行为滑入 生产。这里有一个简单的办法上的NuGet,这里克·安德森 涵盖在这里:

http://blogs.msdn.com/b/rickandy/archive/2012/09/17/asp-net-mvc-4-mobile-caching-bug-fixed.aspx

参见评论在这个岗位 http://www.hanselman.com/blog/MakingASwitchableDesktopAndMobileSiteWithASPNETMVC4AndJQueryMobile.aspx

如果你有一个自定义视图引擎(像我一样),你可以在安装nuget包后更改基类:

public class SiteIdentityViewEngine : Microsoft.Web.Mvc.FixedRazorViewEngine, IVirtualPathFactory