【发布时间】:2013-05-15 07:22:27
【问题描述】:
我可以将 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/
【问题讨论】:
标签: .net-3.5 asp.net-web-api servicestack