在远程服务器上运行时出现以下错误。在本地IIS上它工作正常。
错误CS1061:'object'不包含'Surname'的定义,并且没有扩展方法'Surname'接受类型'object'的第一个参数可以找到
模型 - (在一个单独的项目中)
[Required]
[Display(Name = "First Names")]
public string FirstNames { get; set; }
[Required]
public string Surname { get; set; }
控制器
public ActionResult Index()
{
var applicationForm = new ApplicationForm();
ApplicationFormInfo.LoadInfoMembers();
return View(applicationForm);
}
查看
<%@ Control Language="C#"Inherits="System.Web.Mvc.ViewUserControl<USB_ED.Models.ApplicationF orm>" %> <fieldset> <legend class="hideLegend"></legend> <label for="course"><strong>Select Course</strong></label> <select id="course"></select> </fieldset> <fieldset id="personalInformation"> <legend>Personal Information</legend> <div class="studentDetails fieldRow inline"> <table> <colgroup> <col style="width:auto"/> <col style="width:180px"/> <col style="width:auto" /> </colgroup> <tr> <td><%: Html.LabelFor(m => m.Surname) %></td> <td><%: Html.TextBoxFor(m => m.Surname) %></td> <td colspan="2"><%: Html.ValidationMessageFor(m => m.Surname) %></td> </tr>
的Web.Config
<?xml version="1.0" encoding="utf-8"?>
<!--
For more information on how to configure your ASP.NET application, please visit
http://go.microsoft.com/fwlink/?LinkId=169433
-->
<configuration>
<appSettings>
<add key="webpages:Version" value="2.0.0.0" />
<add key="webpages:Enabled" value="false" />
<add key="PreserveLoginUrl" value="true" />
<add key="ClientValidationEnabled" value="true" />
<add key="UnobtrusiveJavaScriptEnabled" value="true" />
</appSettings>
<system.web>
<httpRuntime targetFramework="4.5" />
<compilation debug="true" targetFramework="4.5" />
<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" />
<handlers>
<remove name="ExtensionlessUrlHandler-Integrated-4.0" />
<remove name="OPTIONSVerbHandler" />
<remove name="TRACEVerbHandler" />
<add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="*" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" />
</handlers>
</system.webServer>
<runtime>
<!--<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="WebGrease" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-1.5.2.14234" newVersion="1.5.2.14234" />
</dependentAssembly>
</assemblyBinding>-->
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Web.Helpers" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-2.0.0.0" newVersion="2.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-2.0.0.0" newVersion="2.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="WebGrease" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-1.5.2.14234" newVersion="1.5.2.14234" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
</pre>
远程服务器和本地计算机已安装MVC 4和Dot Net Framework 4.5。 我的模型是一个单独的项目。我怀疑问题出在远程IIS或web.config文件中。你能帮忙吗?