0

我有一个要添加到 Sitefinity 安装的端点。本质上,我将调用一个 API,然后将一些 json 返回到另一个页面的 AJAX 调用。

我想我可以创建一个空白模板和一个自定义小部件,因为我有创建 Sitefinity MVC 小部件的经验。

不过,可能有一种不太错误的方法来做到这一点。我能否以某种方式(除了在 CMS 中创建一个空白主题和一个自定义小部件之外无需做更多工作)创建一个可公开访问的一次性 C# 页面吗?

4

1 回答 1

2

我认为您在谈论经典 MVC 模式

1)您可以在 Global.asax 中定义路线

protected void Application_Start(object sender, EventArgs e)
{
    Bootstrapper.Initialized += Bootstrapper_Initialized;
}

void Bootstrapper_Initialized(object sender, Telerik.Sitefinity.Data.ExecutedEventArgs e)
{
    if (e.CommandName == "Bootstrapped")
    {
        System.Web.Mvc.RouteCollectionExtensions.MapRoute(System.Web.Routing.RouteTable.Routes,
         "Classic",
         "customprefix/{controller}/{action}/{id}",
         new { controller = "Feature", action = "Index", id = (string)null }
        );
    }
}

2) 使用 Views 和 Models 创建普通的 MVC 控制器

3) 通过这个 URL 访问它http://localhost/customprefix/{controller}/{action}/{id}

于 2017-08-18T18:33:46.970 回答