正在获取UWP应用程序的脱机HttpResponse

正在获取UWP应用程序的脱机HttpResponse,uwp,c++-cx,cpprest-sdk,Uwp,C++ Cx,Cpprest Sdk,我正在使用通用Windows平台应用程序。作为客户端,此应用程序需要调用Web服务。因此,我在项目中添加了C++ REST SDK。我能够调用HTTP请求,并且也得到了响应。 当我断开与互联网的连接时,我不希望有任何回应。但我还是得到了离线的回应。我正在Windows 10上使用Visual Studio 2017。这个项目是用C++/CX编写的。 下面是我的代码: void PrintResponse(http_response response) { // Display the statu

我正在使用通用Windows平台应用程序。作为客户端,此应用程序需要调用Web服务。因此,我在项目中添加了C++ REST SDK。我能够调用HTTP请求,并且也得到了响应。 当我断开与互联网的连接时,我不希望有任何回应。但我还是得到了离线的回应。我正在Windows 10上使用Visual Studio 2017。这个项目是用C++/CX编写的。 下面是我的代码:

void PrintResponse(http_response response)
{
// Display the status code that the server returned
std::wostringstream stream;

auto bodyStream = response.body();
streams::stringstreambuf sbuffer;
auto& target = sbuffer.collection();

bodyStream.read_to_end(sbuffer).get();

OutputDebugStringA(target.c_str()); 
}

pplx::task<void> HTTPGetAsync()
{
http_client client(U("http://microblogging.wingnity.com/JSONParsingTutorial/jsonActors"));
// Make an HTTP GET request and asynchronously process the response
return client.request(methods::GET).then([](http_response response)
{
    PrintResponse(response);
});
}


MainPage::MainPage(){
InitializeComponent();
StudentListView->ItemsSource = Student::CreateStudent();

HTTPGetAsync();
}
void打印响应(http\u响应)
{
//显示服务器返回的状态代码
std::wostringstream;
auto-bodyStream=response.body();
streams::stringstreambuf sbuffer;
auto&target=sbuffer.collection();
bodyStream.read_to_end(sbuffer.get();
OutputDebugStringA(target.c_str());
}
任务HTTPGetAsync()
{
http_客户端(U)http://microblogging.wingnity.com/JSONParsingTutorial/jsonActors"));
//发出HTTP GET请求并异步处理响应
返回client.request(methods::GET).then([](http\U响应)
{
打印应答(应答);
});
}
主页::主页(){
初始化组件();
StudentListView->ItemsSource=Student::CreateStustudent();
HTTPGetAsync();
}
请帮我做这个,这样我就不会得到离线回复


提前谢谢。

这是C++/CX还是C++/WinRT?请适当更新您的标记。我不确定您用于http_客户端类型的包装器库,但在您的请求调用中,请尝试将缓存控制标头设置为“无缓存”。