简体   繁体   English

将端点添加到Sitefinity网站

[英]Add endpoint to Sitefinity site

I have an endpoint I want to add to a Sitefinity installation. 我有一个端点要添加到Sitefinity安装中。 Essentially, I'm going to call an API and then return some json to an AJAX call from another page. 本质上,我将调用一个API,然后从另一个页面将一些json返回到AJAX调用。

I figure I can create a blank template and a custom widget that does just that, since I have experience creating Sitefinity MVC widgets. 我认为我可以创建一个空白模板和一个自定义窗口小部件,因为我有创建Sitefinity MVC窗口小部件的经验,因此可以做到这一点。

There is probably a less wrong way to do this though. 不过,可能有一种不太错误的方式来执行此操作。 Can I somehow (without much more work than creating a blank theme and a custom Widget in the CMS) create a one-off C# page that is publicly accessible? 我能以某种方式(除了在CMS中创建空白主题和自定义窗口小部件而做的工作之外)来创建可公开访问的一次性C#页面吗?

I think you are talking about Classic MVC mode 我认为您是在谈论经典MVC模式

1) You can define route in your Global.asax 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) Create normal MVC controller with Views and Models 2)使用视图和模型创建普通的MVC控制器

3) Access it by this URL http://localhost/customprefix/{controller}/{action}/{id} 3)通过此URL http://localhost/customprefix/{controller}/{action}/{id}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM