I have upgraded my ASP.net MVC 2 application to latest MVC 4 with VS 2013 community edition.
我已经升级了我的ASP.net MVC 2应用到最新的MVC 4和VS 2013社区版。
Everything is completely perfect everything works expect one annoying thing i tried a lot but i didn't find any solution.
一切都是完美的,一切都是完美的,期待着一件烦人的事,我尝试了很多,但我没有找到任何解决办法。
In my razor views it shows me that the Styles, Script, Html.RenderPartial as the following:
在我的razor视图中,它向我展示了样式、脚本、Html。RenderPartial方法如下:
The name 'Scripts' does not exist in the current context
“Scripts”的名称在当前上下文中不存在
During the run time i had no issue at all only during the modification of the view in visual studio:
在运行期间,我没有任何问题,只有在visual studio修改视图时:
http://i.stack.imgur.com/WPAWJ.png
http://i.stack.imgur.com/WPAWJ.png
I tried to add the namespaces in the web.config file (root and the one inside the views) but it doesn't help also, i have the following config:
我尝试在web中添加名称空间。配置文件(根文件和视图内部的配置文件),但它也没有帮助,我有以下配置:
Root web.config:
根web . config:
<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.Optimization" />
<add namespace="System.Web.Routing" />
<add namespace="System.Web.WebPages" />
<add namespace="System.Linq" />
<add namespace="System.Collections.Generic" />
<add namespace="Telerik.Web.Mvc.UI" />
</namespaces>
</pages>
View web.config:
查看web . config:
<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.Mvc" />
<add namespace="System.Web.Mvc.Ajax" />
<add namespace="System.Web.Mvc.Html" />
<add namespace="System.Web.Optimization"/>
<add namespace="System.Web.Routing" />
</namespaces>
</pages>
I tried to restart visual studio a lot, de-attach and attach the project again with no success :(
我试着重新启动visual studio很多次,解除连接并重新连接项目,但没有成功:
Any suggestion or help is really appreacted becuase i would to convert my whole project from aspx/ascx to cshtml
任何建议或帮助都是非常感激的,因为我将把我的整个项目从aspx/ascx转换为cshtml
1 个解决方案
#1
1
Just try this
试试这个
@section Scripts{
<script src="@System.Web.Optimization.BundleTable.Bundles.ResolveBundleUrl("~/bundles/jqueryval")"></script>
}
#1
1
Just try this
试试这个
@section Scripts{
<script src="@System.Web.Optimization.BundleTable.Bundles.ResolveBundleUrl("~/bundles/jqueryval")"></script>
}