我周五离开时,我的应用程序在开发模式下工作......我今天早上进来,没有使用 Layout.Mobile.chtml ......这是开发模式,所以我仍然每次都启动 Web 服务器。 ...我读到了与缓存相关的类似问题....但我看不出这与我的问题有什么关系,因为一旦 Web 服务器关闭,缓存就会被清除。
我使用 Visual Studio 2012 作为我的开发“Web 服务器”。
一切都在运行,我看不出问题出在哪里,也不知道下一步该往哪里看。任何有关如何诊断此问题或在哪里查看的建议将不胜感激。
这仅适用于 Layout.Mobile.cshtml....当我切换回 Layout.cshtml 时,它被调用得很好....
在我的 global.asax.cs 中,我设置了以下设置来强制 firefox 使用移动布局显示:
//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>© @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") © @DateTime.Now.Year - Turning Basin Services</h4>
</div>
</div>
</body>
</html>
在我的观点中,我通常使用 viewstart 将视图设置为隐式映射到布局......但是,我的 .Login.Mobile.cshtml 将关联硬连线到移动布局,如下所示:
@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")
}