我可以将 ServiceStack Web 服务与 .net framework 3.5 Web 表单一起使用吗?
我可以举个小例子吗,因为我尝试过https://github.com/ServiceStack/ServiceStack/wiki/Your-first-webservice-explained并停在“让我们看看 AppHost 的配置方法”行,我不知道该怎么办?
当我读到它类似于 Web API 并且因为 ServiceStack 在 3.5 下工作所以我猜我可以使用它,还是我弄错了?
更新:答案是我必须创建AppHost
并将其添加到Application_Start
:
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(Container container)
{
//register user-defined REST-ful urls
Routes
.Add<Hello>("/hello")
.Add<Hello>("/hello/{Name}");
}
}
//Initialize your application singleton
protected void Application_Start(object sender, EventArgs e)
{
new HelloAppHost().Init();
}
}
参考和完整的例子可以在这里找到:http ://servicestack.net/ServiceStack.Hello/