作者:旭89浪子_499 | 来源:互联网 | 2023-09-24 17:11
InmyCSfileImexecutingthefollowinganditworksasexpected.在我的CS文件中,我正在执行以下操作,它按预期工作。usin
In my CS file I'm executing the following and it works as expected.
在我的CS文件中,我正在执行以下操作,它按预期工作。
using System.Web.Helpers;
String json = System.Web.Helpers.Json.Encode(null);
However, in my CSHTML file I'm executing the following, and here, I get an error about Json not being recognized in the context.
但是,在我的CSHTML文件中,我正在执行以下操作,在这里,我得到一个关于Json无法在上下文中被识别的错误。
@{ Layout = null; }
@using TestService.ServiceReference;
@using System.Web.Helpers;
...
Index
2.Compiled and ran the application, received the following error: CS0103: The name 'Json' does not exist in the current context
.
2.编译并运行应用程序,收到以下错误:CS0103:当前上下文中不存在名称“Json”。
3.Attempted to import namespace in View, added assembly to Views web.config, ensured proper reference in project. None of these had an effect.
3.试图在View中导入名称空间,将组件添加到Views web.config,确保在项目中正确引用。这些都没有影响。
4.The Solution Added the following lines (
) to my web.config in the compilation section (the primary web.config, not the Views folder one)
4.解决方案在我的web.config中添加了以下行(
)编译部分(主要的web.config,而不是Views文件夹之一)
5.Recompile and here is the resulting HTML page output sans error
5.Recompile,这里是生成的HTML页面输出sans错误
Index