我有一个 MVC4 Web 应用程序在我的开发机器上运行,没有任何问题,但是一旦我将它部署到主机服务器,我就会抛出以下异常@using(Html.BeginForm())
。
字符串未被识别为有效的布尔值。 说明:执行当前 Web 请求期间发生未处理的异常。请查看堆栈跟踪以获取有关错误及其源自代码的位置的更多信息。 异常详细信息:System.FormatException:字符串未被识别为有效的布尔值。 源错误: 第 4 行: 第 5 行: 第 6 行:@using(Html.BeginForm(new { returnurl = ViewBag.Returnurl })) 第 7 行:{ 第 8 行:@Html.AntiForgeryToken() 源文件:e:\Sites\familybook\Views\Login\Login.cshtml 行:6 堆栈跟踪: [FormatException:字符串未被识别为有效的布尔值。] System.Boolean.Parse(字符串值)+12636900 System.Convert.ChangeType(Object value, Type conversionType, IFormatProvider provider) +12819466 System.Web.Mvc.ViewContext.ScopeGet(IDictionary`2 scope, String name, TValue defaultValue) +89 System.Web.Mvc.ScopeCache..ctor(IDictionary`2 范围) +48 System.Web.Mvc.ScopeCache.Get(IDictionary`2 范围,HttpContextBase httpContext) +282 System.Web.Mvc.ViewContext.GetClientValidationEnabled(IDictionary`2 范围,HttpContextBase httpContext)+9 System.Web.Mvc.Html.FormExtensions.FormHelper(HtmlHelper htmlHelper, String formAction, FormMethod 方法, IDictionary`2 htmlAttributes) +162 System.Web.Mvc.Html.FormExtensions.BeginForm(HtmlHelper htmlHelper,对象 routeValues)+192 ASP._Page_Views_Login_Login_cshtml.Execute() 在 e:\Sites\familybook\Views\Login\Login.cshtml:6 System.Web.WebPages.WebPageBase.ExecutePageHierarchy() +280 System.Web.Mvc.WebViewPage.ExecutePageHierarchy() +125 System.Web.WebPages.StartPage.ExecutePageHierarchy() +143 System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage) +181 System.Web.Mvc.ViewResultBase.ExecuteResult(ControllerContext 上下文)+380 System.Web.Mvc.c__DisplayClass1a.b__17() +33 System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilter(IResultFilter 过滤器,ResultExecutingContext preContext,Func`1 延续)+613 System.Web.Mvc.ControllerActionInvoker.InvokeActionResultWithFilters(ControllerContext controllerContext, IList`1 过滤器, ActionResult actionResult) +263 System.Web.Mvc.Async.c__DisplayClass25.b__22(IAsyncResult asyncResult) +230 System.Web.Mvc.c__DisplayClass1d.b__18(IAsyncResult asyncResult) +28 System.Web.Mvc.Async.c__DisplayClass4.b__3(IAsyncResult ar) +20 System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult asyncResult) +53 System.Web.Mvc.Async.c__DisplayClass4.b__3(IAsyncResult ar) +20 System.Web.Mvc.c__DisplayClass8.b__3(IAsyncResult asyncResult) +42 System.Web.Mvc.Async.c__DisplayClass4.b__3(IAsyncResult ar) +20 System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +469 System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +375 版本信息:Microsoft .NET Framework 版本:4.0.30319;ASP.NET 版本:4.0.30319.272
主机服务器是 Windows server 2008 R2 64 位,带有 IIS 7.5 和最新的 OS 更新和 .NET 4 框架安装在上面。
有趣的是,当我在使用 Windows 更新更新服务器之前,我在部署之前没有收到此错误。我注意到的另一件事是,如果我将发布类型设置为调试应用程序没有任何问题,而发布发布类型则没有。
我也尝试部署到我的开发机器上的本地文件夹,然后将内容复制到主机服务器,但得到了相同的最终结果。
编辑:
@model FamilyBook.Models.Account.LoginUserModel
@Scripts.Render("~/bundles/jqueryval")
<section>
@using(Html.BeginForm(new { returnurl = ViewBag.Returnurl }))
{
@Html.AntiForgeryToken()
@Html.ValidationSummary(true)
<fieldset>
<legend>Login with local account</legend>
<div class="editor-label">
@Html.LabelFor(model => model.Username)
</div>
<div class="editor-field">
@Html.EditorFor(model => model.Username)
@Html.ValidationMessageFor(model => model.Username)
</div>
<div class="editor-label">
@Html.LabelFor(model => model.Password)
</div>
<div class="editor-field">
@Html.PasswordFor(model => model.Password)
@Html.ValidationMessageFor(model => model.Password)
</div>
<div class="editor-label">
@Html.LabelFor(model => model.RememberMe)
</div>
<div class="editor-field">
@Html.CheckBoxFor(model => model.RememberMe)
</div>
<p>
<input type="submit" value="Login" />
</p>
</fieldset>
}
</section>