我有一個可以在本地完美工作的剃鬚刀2.0格式。我已經驗證過,針對MVC,Razor和helpers的dll都是最新版本。我在每個使用@Html.BeginForm
的頁面上都有這個例外,並且參數不一樣。 MVC的網頁似乎工作正常,只要沒有形成傭工使用:MVC 4.0字符串未被識別爲有效的布爾值
Exception:
[FormatException: String was not recognized as a valid Boolean.]
System.Boolean.Parse(String value) +13981920
System.Convert.ChangeType(Object value, Type conversionType, IFormatProvider
provider) +811
System.Web.Mvc.ViewContext.ScopeGet(IDictionary`2 scope, String name, TValue
defaultValue) +89
System.Web.Mvc.ScopeCache..ctor(IDictionary`2 scope) +75
System.Web.Mvc.ScopeCache.Get(IDictionary`2 scope, HttpContextBase httpContext) +299
System.Web.Mvc.ViewContext.GetClientValidationEnabled(IDictionary`2 scope,
HttpContextBase
httpContext) +9
System.Web.Mvc.Html.FormExtensions.FormHelper(HtmlHelper htmlHelper, String formAction,
`enter code here`FormMethod method, IDictionary`2 htmlAttributes) +233
System.Web.Mvc.Html.FormExtensions.BeginForm(HtmlHelper htmlHelper, String actionName,
String controllerName, FormMethod method, Object htmlAttributes) +134
ASP._Page_Views_Portal_LoginForm_cshtml.Execute() in
e:\WebRoot\NW_QA_BleedHR\Views\Portal\LoginForm.cshtml:4
System.Web.WebPages.WebPageBase.ExecutePageHierarchy() +280
System.Web.Mvc.WebViewPage.ExecutePageHierarchy() +125
System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext,
TextWriter writer, WebPageRenderingBase startPage) +196
System.Web.Mvc.Html.PartialExtensions.Partial(HtmlHelper htmlHelper, String
partialViewName, Object model, ViewDataDictionary viewData) +147
ASP._Page_Views_Portal_Welcome_cshtml.Execute() in
e:\WebRoot\NW_QA_BleedHR\Views\Portal\Welcome.cshtml:9
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 context)
+380
System.Web.Mvc.<>c__DisplayClass1a.<InvokeActionResultWithFilters>b__17()
+33
System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilter(IResultFilter filter,
ResultExecutingContext preContext, Func`1 continuation) +613
System.Web.Mvc.ControllerActionInvoker.InvokeActionResultWithFilters(ControllerContext
controllerContext, IList`1 filters, ActionResult actionResult) +263
System.Web.Mvc.Async.<>c__DisplayClass25.<BeginInvokeAction>b__22(IAsyncResult
asyncResult) +240
System.Web.Mvc.<>c__DisplayClass1d.<BeginExecuteCore>b__18(IAsyncResult asyncResult) +28
System.Web.Mvc.Async.<>c__DisplayClass4.<MakeVoidDelegate>b__3(IAsyncResult ar) +15
System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult asyncResult) +53
System.Web.Mvc.Async.<>c__DisplayClass4.<MakeVoidDelegate>b__3(IAsyncResult ar) +15
System.Web.Mvc.<>c__DisplayClass8.<BeginProcessRequest>b__3(IAsyncResult asyncResult) +42
System.Web.Mvc.Async.<>c__DisplayClass4.<MakeVoidDelegate>b__3(IAsyncResult ar) +15
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
+606
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean&
completedSynchronously) +288
這種形式是死的簡單:
@model GIS.Pangea.NW.Presentation.ViewModels.LoginView
<div id="DOAlogin_div">
@using (Html.BeginForm("CandidateLogin", "account", FormMethod.Post, new { id = "loginform" }))
{
@Html.AntiForgeryToken()
@Html.ValidationSummary()
<table id="loginForm_tb">
<tr>
<td colspan="2" id="loginHeader_td">
<h3 id="loginHeader_h3">@Model.ReturningApplicantText</h3>
</td>
</tr>
<tr>
<td class="fieldName_td" id="username_td">
@Html.LabelFor(p=>Model.LoginDto.UserName)
</td>
<td class="fieldData_td" id="usernameinput_td">
@Html.TextBoxFor(p => Model.LoginDto.UserName, new {id="UserName",Name="UserName" })
@Html.ValidationMessage("UserName")
</td>
</tr>
<tr>
<td class="fieldName_td" id="password_td">
<label for="Password">
@Html.Encode(Model.PasswordText)
</label>
</td>
<td class="fieldData_td" id="passwordinput_td">
@Html.PasswordFor(p=>Model.LoginDto.Password, new {id="Password",Name="Password" })
@Html.ValidationMessage("Password")
</td>
</tr>
<tr>
<td colspan="2" id="forgotPassword_td">
@Html.ActionLink("Forgot Username or Password?","ForgotPassword")
</td>
</tr>
<tr>
<td colspan="2" id="loginSubmit_td" class="submit_td">
<input type="submit" class="formButton" value="@Model.LoginButtonText" />
</td>
</tr>
<tr>
<td colspan="2" id="loginValidation_td">
@if (!String.IsNullOrEmpty(Model.LoginDto.ValidationMessage))
{
<span class="validationMessage">@Model.LoginDto.ValidationMessage</span>
}
</td>
</tr>
</table>
}
</div>
我最初懷疑DLL的錯誤或丟失的版本。所有MVC組件應該在bin文件夾,我已經驗證了這一點(至少在頂層的dll)
Here is my view config file:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<sectionGroup name="system.web.webPages.razor" type="System.Web.WebPages.Razor.Configuration.RazorWebSectionGroup, System.Web.WebPages.Razor, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
<section name="host" type="System.Web.WebPages.Razor.Configuration.HostSection, System.Web.WebPages.Razor, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" />
<section name="pages" type="System.Web.WebPages.Razor.Configuration.RazorPagesSection, System.Web.WebPages.Razor, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" />
</sectionGroup>
</configSections>
<system.web.webPages.razor>
<host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<pages pageBaseType="System.Web.Mvc.WebViewPage">
<namespaces>
<add namespace="System.Web.Helpers" />
<add namespace="System.Web.Mvc" />
<add namespace="System.Web.Mvc.Ajax" />
<add namespace="System.Web.Mvc.Html" />
<add namespace="System.Web.Optimization" />
<add namespace="System.Web.Routing" />
<add namespace="MVCControlsToolkit.Core" />
<add namespace="MVCControlsToolkit.Controls" />
<add namespace="MVCControlsToolkit.Controls.Validation" />
</namespaces>
</pages>
</system.web.webPages.razor>
<appSettings>
<add key="webpages:Enabled" value="false" />
</appSettings>
<system.web>
<compilation debug="false" targetFramework="4.5">
<assemblies>
<add assembly="System.Web.Mvc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
<add assembly="System.Web.WebPages, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
<add assembly="System.Web.Helpers, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
<add assembly="System.Web.WebPages.Razor, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
</assemblies>
</compilation>
<httpHandlers>
<add path="*" verb="*" type="System.Web.HttpNotFoundHandler" />
</httpHandlers>
<pages validateRequest="false" pageParserFilterType="System.Web.Mvc.ViewTypeParserFilter, System.Web.Mvc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" pageBaseType="System.Web.Mvc.ViewPage, System.Web.Mvc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" userControlBaseType="System.Web.Mvc.ViewUserControl, System.Web.Mvc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
<controls>
<add assembly="System.Web.Mvc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" namespace="System.Web.Mvc" tagPrefix="mvc" />
</controls>
</pages>
</system.web>
<system.webServer>
<validation validateIntegratedModeConfiguration="false" />
<handlers>
<remove name="BlockViewHandler" />
<add name="BlockViewHandler" path="*" verb="*" preCondition="integratedMode" type="System.Web.HttpNotFoundHandler" />
</handlers>
</system.webServer>
</configuration>
This project uses a combination of ASP pages and MVC Views, and previously was working with webforms 1.0 and MVC 2.0. The application is setup as an application under the default website. I've seen lots of variations with this same exception but most came down to syntax errors in the form helpers. This seems to be more environmentally related. Any help would be greatly appreciated!
請你可以從你的.cshtml文件中發佈一個代碼樣本導致錯誤?在剃刀視圖中使用表單的推薦方法是使用一個使用語句,即@using(Html.BeginForm()){}不知道這是否有助於... – 2013-05-14 18:27:35
嗨,解決您的問題的任何運氣?有同樣的問題,但無法找到解決方案。 – Alyek 2013-06-05 07:21:31