命名空间的问题与MVC视图 - 剃刀引擎 [英] Namespace issue with MVC view - Razor engine

查看:131
本文介绍了命名空间的问题与MVC视图 - 剃刀引擎的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我添加参考System.Web.DataVisualization到我的MVC项目。
现在,当我试图将命名空间添加到我的web.config我收到错误

I added reference to the System.Web.DataVisualization to my MVC project. Now when I try to add the namespace to my web.config I am getting error

CS0234:类型或命名空间名称数据可视化并不在命名空间'的System.Web.UI(是否缺少程序集引用)存在

CS0234: The type or namespace name 'DataVisualization' does not exist in the namespace 'System.Web.UI' (are you missing an assembly reference?)

于是我尝试用相同的在我的控制器。这完美的作品。

So then I try to use the same in my controller. This works perfectly.

using System.Web.UI.DataVisualization;

那么同样应该在我的Razor视图工作

Then the same should work in my Razor view

所以我尝试在我的Razor视图使用此

So I try to use this in my Razor view

@using System.Web.UI.DataVisualization;

这又不不行给我同样的错误。

This again not not work giving me the same error

为什么我可以使用该命名空间在我的控制器,而不是在我的意见?

How come I can use the namespace in my controller and not in my views?

我缺少的东西...

推荐答案

如果你去到项目引用,在属性上的System.Web.DataVisualization,然后设置CopyLocal为true,接下来会能够把

If you go to the project references, go to properties on "System.Web.DataVisualization," then set "CopyLocal" to true, you'll then be able to put

@using System.Web.UI.DataVisualization

在您的Razor视图。

in your Razor view.

这篇关于命名空间的问题与MVC视图 - 剃刀引擎的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆