Last active
July 24, 2019 14:01
-
-
Save sitefinitysteve/86e05160c2e2be5410dcc754549c272a to your computer and use it in GitHub Desktop.
This is everything you need to register a servicestack service in Sitefinity. Just set your Route, and make sure to register the plugin!
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using Telerik.Sitefinity; | |
using Telerik.Sitefinity.Model; | |
using Telerik.Sitefinity.DynamicModules; | |
using Telerik.Sitefinity.Data.Linq.Dynamic; | |
using Telerik.Sitefinity.Services.Search; | |
using Telerik.Sitefinity.Utilities.TypeConverters; | |
using ServiceStack.Text; | |
using ServiceStack; | |
using Telerik.Sitefinity.DynamicModules.Model; | |
namespace SitefinityWebApp.Services { | |
#region PLUGIN | |
public class HelloServicePlugin : IPlugin { | |
/// <summary> | |
/// In Global.asax.cs in Application_Start make sure to call the SystemManager.RegisterServiceStackPlugin(new SitefinityWebApp.Services.HelloServicePlugin());; | |
/// </summary> | |
public void Register(IAppHost appHost) { | |
appHost.RegisterService(typeof(HelloService)); | |
} | |
} | |
#endregion | |
#region SERVICE | |
public class HelloService : ServiceStack.Service { | |
public object Get(HelloRequest request) | |
{ | |
return "Hello {0}".Arrange(request.Name); | |
} | |
} | |
#endregion | |
#region REQUEST | |
//This is available at https://<domain>/RestApi/myservice/hello | |
[Route("/myservice/hello")] | |
public class HelloRequest : IReturn<string> | |
{ | |
public string Name { get; set; } | |
} | |
#endregion | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment