GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — ServiceStack.Examples/src/ServiceStack.Hello/Global.asax.cs at master · namman/ServiceStack.Examples Expand file tree/ Copy pathGlobal.asax.csMore file actions 70 lines (64 loc) · 2.42 KB / Copy pathGlobal.asax.csFile metadata and controls70 lines (64 loc) · 2.42 KB 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 using System; using Funq; using ServiceStack.ServiceHost; using ServiceStack.WebHost.Endpoints; namespace ServiceStack.Hello { /// <summary> /// Define your ServiceStack web service request (i.e. the Request DTO). /// </summary> public class Hello { public string Name { get; set; } } /// <summary> /// Define your ServiceStack web service response (i.e. Response DTO). /// </summary> public class HelloResponse { public string Result { get; set; } } /// <summary> /// Create your ServiceStack web service implementation. /// </summary> public class HelloService : IService<Hello> { public object Execute(Hello request) { //Looks strange when the name is null so we replace with a generic name. var name = request.Name ?? "John Doe"; return new HelloResponse { Result = "Hello, " + name }; } } public class Global : System.Web.HttpApplication { /// <summary> /// Create your ServiceStack web service application with a singleton AppHost. /// </summary> public class HelloAppHost : AppHostBase { /// <summary> /// Initializes a new instance of your ServiceStack application, with the specified name and assembly containing the services. /// </summary> public HelloAppHost() : base("Hello Web Services", typeof(HelloService).Assembly) { } /// <summary> /// Configure the container with the necessary routes for your ServiceStack application. /// </summary> /// <param name="container">The built-in IoC used with ServiceStack.</param> public override void Configure(Container container) { //Register user-defined REST-ful urls. You can access the service at the url similar to the following. //http://localhost/ServiceStack.Hello/servicestack/hello or http://localhost/ServiceStack.Hello/servicestack/hello/John%20Doe //You can change /servicestack/ to a custom path in the web.config. Routes .Add<Hello>("/hello") .Add<Hello>("/hello/{Name}"); } } protected void Application_Start(object sender, EventArgs e) { //Initialize your application (new HelloAppHost()).Init(); } } } |
| You are visitor 01402792 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |