我想使用Web部署方法将Web应用程序部署到测试服务器。应用程序正常构建没有问题,并在本地和测试服务器上正常工作当我想在部署期间使用预编译设置时出现问题。在这个过程中,我在VerifyCode.cshtml
文件中遇到了大量错误。事情是我在我的视图文件夹中甚至没有名为VerifyCode
的视图。问题出在哪儿?我正在并行使用匿名和Windows身份验证。
接收示例错误:
The name 'ViewBag' does not exist in the current context
The name 'Scripts' does not exist in the current context
The name 'Model' does not exist in the current context
'HtmlHelper' does not contain a definition for 'TextBoxFor' ...
等等 ...
VerifyCode.cshtml
代码:
@model App.Models.VerifyCodeViewModel
@{
ViewBag.Title = "Verify";
}
<h2>@ViewBag.Title.</h2>
@using (Html.BeginForm("VerifyCode", "Account", new { ReturnUrl = Model.ReturnUrl }, FormMethod.Post, new { @class = "form-horizontal", role = "form" })) {
@Html.AntiForgeryToken()
@Html.Hidden("provider", @Model.Provider)
@Html.Hidden("rememberMe", @Model.RememberMe)
<h4>Enter verification code</h4>
<hr />
@Html.ValidationSummary("", new { @class = "text-danger" })
<div class="form-group">
@Html.LabelFor(m => m.Code, new { @class = "col-md-2 control-label" })
<div class="col-md-10">
@Html.TextBoxFor(m => m.Code, new { @class = "form-control" })
</div>
</div>
<div class="form-group">
<div class="col-md-offset-2 col-md-10">
<div class="checkbox">
@Html.CheckBoxFor(m => m.RememberBrowser)
@Html.LabelFor(m => m.RememberBrowser)
</div>
</div>
</div>
<div class="form-group">
<div class="col-md-offset-2 col-md-10">
<input type="submit" class="btn btn-default" value="Submit" />
</div>
</div>
}
@section Scripts {
@Scripts.Render("~/bundles/jqueryval")
}
好的,我设法让它工作。这个问题很简单。我不知道我的项目中是如何在随机位置上调用VerifyCode
的。
有趣的是,VS搜索文本工具无法找到它。我做了一些研究,例如here发现VS中的文本搜索存在一些问题,但并不总是按预期工作。
因此,虽然预编译了视图,但所有视图文件都与这个偷偷摸摸的文件一起被删除而没有引用。