我可以在.net framework 3.5 网络表单中使用ServiceStack网络服务吗?
我可以举一个小例子,因为我试图通过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/
答案 0 :(得分:2)
ServiceStack支持.NET 3.5。您可以在NuGet包中签出程序集,它们是在.NET 3.5中编译的。它不依赖于Web API,您可以从空的ASP.NET应用程序创建Web服务。
答案 1 :(得分:1)