Validation.RequireField:CS0117:'System.Web.Helpers.Validation'不包含'RequireField'的定义

[英]Validation.RequireField:CS0117: 'System.Web.Helpers.Validation' does not contain a definition for 'RequireField'


i create an mvc4 webpage2 razor web project and when i use Validation.RequireField it gives me this error but when i create new website it works fine.i get confused what is the problem????

我创建一个mvc4 webpage2剃刀web项目,当我使用Validation.RequireField它给了我这个错误,但当我创建新的网站,它工作正常。我弄糊涂是什么问题????

CS0117: 'System.Web.Helpers.Validation' does not contain a definition for 'RequireField'

CS0117:'System.Web.Helpers.Validation'不包含'RequireField'的定义

@model   Common.UsersManagement.Extensions.LoginModel
@{
    Validation.RequireField("title", "You must enter a title");

}

this my web config

这是我的网络配置

<configuration>
  <connectionStrings>
    <add name="DefaultConnection" connectionString="Data Source=localhost;Initial Catalog=NaturalEnvironment;Integrated Security=True;" providerName="System.Data.SqlClient" />
  </connectionStrings>
  <appSettings>
    <add key="webpages:Version" value="2.0.0.0" />
    <add key="webpages:Enabled" value="true" />
    <add key="PreserveLoginUrl" value="true" />
    <add key="ClientValidationEnabled" value="true" />
    <add key="UnobtrusiveJavaScriptEnabled" value="true" />
  </appSettings>
  <system.web>
    <customErrors mode="Off" defaultRedirect="~/Shared/ErrorPage">
    </customErrors>
    <sessionState timeout="20"></sessionState>
    <compilation debug="true" targetFramework="4.0" />
    <pages>
      <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.Routing" />
        <add namespace="System.Web.WebPages" />
      </namespaces>
    </pages>
  </system.web>
  <system.webServer>
    <validation validateIntegratedModeConfiguration="false" />
    <modules runAllManagedModulesForAllRequests="true" />
    <handlers>
      <remove name="ExtensionlessUrlHandler-ISAPI-4.0_32bit" />
      <remove name="ExtensionlessUrlHandler-ISAPI-4.0_64bit" />
      <remove name="ExtensionlessUrlHandler-Integrated-4.0" />
      <add name="ExtensionlessUrlHandler-ISAPI-4.0_32bit" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework\v4.0.30319\aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv4.0,bitness32" responseBufferLimit="0" />
      <add name="ExtensionlessUrlHandler-ISAPI-4.0_64bit" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework64\v4.0.30319\aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv4.0,bitness64" responseBufferLimit="0" />
      <add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" />
    </handlers>
  </system.webServer>
</configuration>

this my packages

这是我的包裹

<packages>
  <package id="Microsoft.AspNet.Mvc" version="4.0.20710.0" targetFramework="net40" />
  <package id="Microsoft.AspNet.Razor" version="2.0.30506.0" targetFramework="net40" />
  <package id="Microsoft.AspNet.WebApi" version="4.0.20710.0" targetFramework="net40"/>
  <package id="Microsoft.AspNet.WebApi.Client" version="4.0.20710.0"   targetFramework="net40" />
      <package id="Microsoft.AspNet.WebApi.Core" version="4.0.20710.0" targetFramework="net40" />
      <package id="Microsoft.AspNet.WebApi.WebHost" version="4.0.20710.0" targetFramework="net40" />
      <package id="Microsoft.AspNet.WebPages" version="2.0.30506.0" targetFramework="net40" />
      <package id="Microsoft.Net.Http" version="2.0.20710.0" targetFramework="net40" />
      <package id="Microsoft.Web.Infrastructure" version="1.0.0.0" targetFramework="net40" />
      <package id="Newtonsoft.Json" version="4.5.6" targetFramework="net40" />
    </packages>

1 个解决方案

#1


1  

You probably have WebMatrix 1. Install WebMatrix 2 or later version using Web Platform Installer.

您可能拥有WebMatrix 1.使用Web Platform Installer安装WebMatrix 2或更高版本。

智能推荐

注意!

本站翻译的文章,版权归属于本站,未经许可禁止转摘,转摘请注明本文地址:http://www.silva-art.net/blog/2013/11/18/e753f781474efe287d83e4acee11df6e.html



 
© 2014-2019 ITdaan.com 粤ICP备14056181号  

赞助商广告