/
Global.asax.cs
58 lines (49 loc) · 1.35 KB
/
Global.asax.cs
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
using System;
using System.ComponentModel;
using System.Runtime.Serialization;
using ServiceStack.ServiceHost;
using ServiceStack.WebHost.Endpoints;
namespace ServiceStack.Hello
{
/// Create the name of your Web Service (i.e. the Request DTO)
public class Hello
{
public string Name { get; set; }
}
/// Define your Web Service response (i.e. Response DTO)
public class HelloResponse
{
public string Result { get; set; }
}
/// Create your Web Service implementation
public class HelloService : IService<Hello>
{
public object Execute(Hello request)
{
return new HelloResponse { Result = "Hello, " + request.Name };
}
}
public class Global : System.Web.HttpApplication
{
/// Web Service Singleton AppHost
public class HelloAppHost : AppHostBase
{
//Tell Service Stack the name of your application and where to find your web services
public HelloAppHost()
: base("Hello Web Services", typeof(HelloService).Assembly) { }
public override void Configure(Funq.Container container)
{
//register user-defined REST-ful urls
Routes
.Add<Hello>("/hello")
.Add<Hello>("/hello/{Name}");
}
}
protected void Application_Start(object sender, EventArgs e)
{
//Initialize your application
var appHost = new HelloAppHost();
appHost.Init();
}
}
}