差分
ナビゲーションに移動
検索に移動
== ステップ4: Webサービスを登録してみる ==
最後にWebサービスを初期化し登録する。
Global.asax.csファイルを以下のように編集する。
<source lang="csharp">
using System;
using System.Collections;
using System.ComponentModel;
using System.Web;
using System.Web.SessionState;
using ServiceStack.WebHost.Endpoints;
public class Global : System.Web.HttpApplication
{
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 any dependencies your services use, e.g:
//container.Register<ICacheClient>(new MemoryCacheClient());
}
}
protected void Application_Start(Object sender, EventArgs e)
{
new HelloAppHost().Init();
}
}
</source>
これで完成である。ServiceStackに関するすべての構成はAppHostで行われる。いわゆるアプリケーションのエントリーポイントのようなものである。
== 動かしてみる ==