我有一个自托管的 WCF 服务作为 Windows 服务运行,使用 WebAPI 来处理 REST 的东西,它工作得很好。
我意识到我真的应该使用 IIS 或类似的东西来输出实际的网页,但是有没有办法让服务调用返回“只是”html?
即使我指定“BodyStye Bare”,我仍然会得到围绕实际 HTML 的 XML 包装器,即
<?xml version="1.0" encoding="UTF-8"?>
<string> html page contents .... </string>
[WebGet(UriTemplate = "/start", BodyStyle = WebMessageBodyStyle.Bare)]
public string StartPage()
{
return System.IO.File.ReadAllText(@"c:\whatever\somefile.htm");
}
有什么办法可以做到这一点还是我应该放弃?