我已使用http://razor.servicestack.net/设置网站。
我已经创建了几个视图和匹配服务,其示例如下:
服务示例:
using ServiceStack.ServiceHost;
using ServiceStack.ServiceInterface;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace website
{
[DefaultView("AboutUs")]
public class AboutUsService : Service
{
public object Get(AboutUsRequest request)
{
return new AboutUsResponse
{
//any properties that need to be set on the response object can be done inline here
};
}
}
[Route("/About-Us")]
public class AboutUsRequest
{
//any request parameters we need can be provided here. They should be auto parsed from the request
}
public class AboutUsResponse
{
//any response properties we want to use in the view can be defined here
}
}
查看示例(位于/Views/AboutUs.cshtml)
@inherits ServiceStack.Razor.ViewPage<website.AboutUsResponse>
<html><body><h1>About Us</h1></body></html>
这在Windows上加载很好,但无法在Mono / NginxFastCGI上加载,而只是显示默认的API快照页面:
Snapshot of AboutUsRequest generated by ServiceStack on 11/17/2012 02:30:14
view json datasource from original url: http://dev.mydomain.com:80/About-Us? in other formats: json xml csv jsv
我需要为Mono / Linux端配置一些特定的更改吗?顺便说一句,我有IOMAP =所有已经打开。
非常感谢任何关于如何使这项工作的想法!
答案 0 :(得分:2)
不幸的是,你遗漏了最重要的部分:Razor视图的名称和位置。
Snaphot页面是ServiceStack无法找到所需视图的后备,在这种情况下,因为您已经指定了[DefaultView(“AboutUs”)],ServiceStack将查找名为“AboutUs.cshtml”的视图“在/ Views /目录中,你拥有的是什么?