【发布时间】:2026-02-05 21:25:01
【问题描述】:
我已按照说明在此处创建 ServiceStack:
https://github.com/ServiceStack/ServiceStack/wiki/Create-your-first-webservice
我确信我已经完全按照它的要求进行操作,但只要我运行 Web 应用程序。我得到了我的回复的“快照”视图。我了解当我没有默认视图/网页时会发生这种情况。我将项目设置为 ASP.net 网站,而不是 ASP.net MVC 网站。会不会是这个问题?
我还使用以下 C# 代码编写了一个测试控制台应用程序。它以 HTML 网页而不是纯字符串的形式获得响应,例如“你好,约翰”。
static void sendHello()
{
string contents = "john";
string url = "http://localhost:51450/hello/";
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
request.Method = "POST";
request.ContentLength = contents.Length;
request.ContentType = "application/x-www-form-urlencoded";
// SEND TO WEBSERVICE
using (StreamWriter writer = new StreamWriter(request.GetRequestStream()))
{
writer.Write(contents);
}
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
string result = string.Empty;
using (StreamReader reader = new StreamReader(response.GetResponseStream()))
{
result = reader.ReadToEnd();
}
Console.WriteLine(result);
}
如何关闭“快照”视图?我做错了什么?
【问题讨论】:
标签: servicestack snapshot