Razor.ServiceStack-视图未呈现,只是默认的“快照" [英] Razor.ServiceStack - Views not rendering, just default "Snapshot"
问题描述
我已经使用 http://razor.servicestack.net/设置了站点.
I've setup a site using http://razor.servicestack.net/.
我已经创建了几个视图和匹配服务,其示例如下:
I've created several views and matching services with an example as follows:
服务示例:
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)
View Example (located at /Views/AboutUs.cshtml)
@inherits ServiceStack.Razor.ViewPage<website.AboutUsResponse>
<html><body><h1>About Us</h1></body></html>
这可以在Windows上很好地加载,但是无法在Mono/NginxFastCGI上加载,而是仅显示默认的API快照页面:
This loads fine on windows, but fails to load on Mono/NginxFastCGI, and instead just shows the default API snapshot page:
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 = all.
Is there some specific change that I need to configure for this to work on the Mono/Linux side? By the way, i have IOMAP=all already turned on.
任何有关如何实现此工作的想法将不胜感激!
Any ideas on how to get this working would be greatly appreciated!
推荐答案
不幸的是,您忽略了最重要的部分:Razor视图的名称和位置.
Unfortunately you left out the most important part: the name and location of the Razor view.
当ServiceStack找不到其要查找的视图时,Snaphot页面是一个后备选项,在这种情况下,由于您已指定[DefaultView("AboutUs")],ServiceStack将寻找一个名为"AboutUs.cshtml"的视图在/Views/目录中,这就是您所拥有的吗?
The Snaphot page is a fallback for when ServiceStack can't find the view it's looking for, in this case since you've specified [DefaultView("AboutUs")], ServiceStack will look for a view named "AboutUs.cshtml" in the /Views/ directory, is that what you have?
这篇关于Razor.ServiceStack-视图未呈现,只是默认的“快照"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!