SDL Tridion C#代码片段无法在上下文中找到引擎,包或日志字段

Bit*_*der 4 c# tridion

我对Tridion开发很新,我遇到了第一个"基本"问题.我在TBB中编写了一个简单的C#代码片段(使用内容管理器文本编辑器),并且我尝试使用引擎,包和日志字段(因为我知道它们由Tridion提供)但我收到错误说"该名称在上下文中不存在".这是代码:

<%@ Page Language="C#" ContentType="text/html" ResponseEncoding="utf-8" %>
<div>
        <!-- TemplateBeginRepeat name="Component.Fields.crociera" -->
              <!-- TemplateBeginIf cond="prezzo<250" -->
                     Go to @@location@@<br/>
              <!-- TemplateEndIf -->
        <!-- TemplateEndRepeat -->
</div>
<%
String ts = DateTime.Now.ToString("d MMM yyyy");
Response.Write("<br/>"+ts);
engine.getSession();
%>
Run Code Online (Sandbox Code Playgroud)

当我保存TBB并发布页面时,我收到此错误:

Compilation Error

Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately. 

Compiler Error Message: CS0103: The name 'engine' does not exist in the current context

Source Error:


Line 31: Response.Write("<br/>"+ts);
Line 32: engine.getSession();
Line 33: %>                         
Line 34:                  </div>

Source File: c:\inetpub\wwwroot\stage\pj\ricerca\ricerca.aspx    Line: 32 
Run Code Online (Sandbox Code Playgroud)

可能我错过了什么或做错了什么,有人认出这个问题吗?

Fra*_*len 11

Engine您使用的对象是Tridion的TOM.NET API的一部分,该API仅在项目发布时可用于您的代码.

一旦ASPX页面到达前端服务器,TOM.NET API就不再可用了.部分原因是Tridion Content Manager无法再从您的Web服务器访问.

您需要通过其API对Tridion Content Delivery进行编程,而不是通过其TOM.NET API对Tridion Content Manager进行编程.您可以在Live Docs中找到常见案例的文档(需要登录).