在我的Razor应用程序中,我无法使用@model
,因为它会抛出The name 'model' does not exist in the current context
的例外我已经尝试过的是
web.config
文件放在与视图相同的文件夹中。web.config
文件,因为我认为它是什么
导致问题。网站布局:
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="3.0" />
</appSettings>
<system.web>
<compilation debug="true" targetFramework="4.5.1" />
<httpRuntime targetFramework="4.5.1" />
</system.web>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Microsoft.Owin" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-3.0.1.0" newVersion="3.0.1.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.Helpers" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-5.2.3.0" newVersion="5.2.3.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
已安装的软件包:
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="bootstrap" version="3.3.2" targetFramework="net451" />
<package id="jQuery" version="1.9.1" targetFramework="net451" />
<package id="Microsoft.AspNet.Mvc" version="5.2.3" targetFramework="net451" />
<package id="Microsoft.AspNet.Razor" version="3.2.3" targetFramework="net451" />
<package id="Microsoft.AspNet.SignalR" version="2.2.0" targetFramework="net451" />
<package id="Microsoft.AspNet.SignalR.Core" version="2.2.0" targetFramework="net451" />
<package id="Microsoft.AspNet.SignalR.JS" version="2.2.0" targetFramework="net451" />
<package id="Microsoft.AspNet.SignalR.SystemWeb" version="2.2.0" targetFramework="net451" />
<package id="Microsoft.AspNet.WebHelpers" version="3.2.3" targetFramework="net451" />
<package id="Microsoft.AspNet.WebPages" version="3.2.3" targetFramework="net451" />
<package id="Microsoft.AspNet.WebPages.Data" version="3.2.3" targetFramework="net451" />
<package id="Microsoft.AspNet.WebPages.WebData" version="3.2.3" targetFramework="net451" />
<package id="Microsoft.Owin" version="3.0.1" targetFramework="net451" />
<package id="Microsoft.Owin.FileSystems" version="3.0.1" targetFramework="net451" />
<package id="Microsoft.Owin.Host.SystemWeb" version="3.0.1" targetFramework="net451" />
<package id="Microsoft.Owin.Security" version="2.1.0" targetFramework="net451" />
<package id="Microsoft.Owin.StaticFiles" version="3.0.1" targetFramework="net451" />
<package id="Microsoft.Web.Infrastructure" version="1.0.0.0" targetFramework="net451" />
<package id="Newtonsoft.Json" version="6.0.8" targetFramework="net451" />
<package id="Owin" version="1.0" targetFramework="net451" />
</packages>
附加说明:
web.config
没有运气,所以在那里我解释了一切
希望有人发现错误的细节。