我试图用libcurl从C++的REST网页下载一个json文件.如果我去网页但以下代码有效但如果我尝试访问json则不下载....
我认为它应该是一个简单的解决方案,但我找不到任何参考...
如果我去网页打开json,但这段代码只返回text/html; 字符集= utf-8的
??????????
CURL *curl;
CURLcode res;
struct curl_slist *headers=NULL; // init to NULL is important
headers = curl_slist_append(headers, "Accept: application/json");
curl = curl_easy_init();
if(curl) {
curl_easy_setopt(curl, CURLOPT_URL, "http://web.com/api/json/123");
curl_easy_setopt(curl, CURLOPT_HTTPGET,1);
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
//curl_easy_setopt(curl, CURLOPT_URL, "http://web.com/123.html");//this works!!!
res = curl_easy_perform(curl);
if(CURLE_OK == res) {
char *ct;
/* ask for the content-type */
res = curl_easy_getinfo(curl, CURLINFO_CONTENT_TYPE, &ct);
if((CURLE_OK == res) && ct)
printf("We received Content-Type: %s\n", ct);
}
}
/* always cleanup */
curl_easy_cleanup(curl);
Run Code Online (Sandbox Code Playgroud) 事件查看器显示以下错误
工作进程无法预加载 .Net 运行时版本无托管代码。
工作进程未能正确初始化,因此无法启动。数据是错误的。
我可以dotnet website.dll从命令行运行并在 Web 浏览器中查看它,但由于某种原因 IIS 不运行 asp.net core 网站。
我已经从这里安装了 Windows 托管 dotnet core 以及 sdk
https://github.com/dotnet/core/blob/master/release-notes/download-archives/
我已将 .net clr 版本设置为“无托管代码”。
我将身份更改为管理员以消除潜在的权限问题
Enable-WindowsOptionalFeature -Online -FeatureName IIS-WebServerRole
Enable-WindowsOptionalFeature -Online -FeatureName IIS-WebServer
Enable-WindowsOptionalFeature -Online -FeatureName IIS-CommonHttpFeatures
Enable-WindowsOptionalFeature -Online -FeatureName IIS-HttpErrors
Enable-WindowsOptionalFeature -Online -FeatureName IIS-HttpRedirect
Enable-WindowsOptionalFeature -Online -FeatureName IIS-ApplicationDevelopment
Enable-WindowsOptionalFeature -Online -FeatureName NetFx4Extended-ASPNET45
Enable-WindowsOptionalFeature -Online -FeatureName IIS-HealthAndDiagnostics
Enable-WindowsOptionalFeature -Online -FeatureName IIS-HttpLogging
Enable-WindowsOptionalFeature -Online -FeatureName IIS-LoggingLibraries
Enable-WindowsOptionalFeature -Online -FeatureName IIS-RequestMonitor
Enable-WindowsOptionalFeature -Online -FeatureName IIS-HttpTracing
Enable-WindowsOptionalFeature -Online -FeatureName …Run Code Online (Sandbox Code Playgroud) 我试图将以下SQL转换为LINQ表达式
SELECT COUNT(ID) AS Count, MyCode
FROM dbo.Archive
WHERE DateSent>=@DateStartMonth AND DateSent<=@DateEndMonth
GROUP BY MyCode
Run Code Online (Sandbox Code Playgroud)
我一直在尝试关注此网页作为示例:
将包含top,count,group和order的SQL转换为LINQ(2个实体)
到目前为止,我得到了这个,但我仍然坚持理解新的部分
var res = (from p in db.Archives
where (p.DateSent>= dateStartMonth) && (p.DateSent< dateToday)
group p by p.MyCode into g
select new { ??????MyCode = g.something?, MonthlyCount= g.Count() });
Run Code Online (Sandbox Code Playgroud)
在此先感谢您的帮助
更新:
你能解释一下g.Key是什么吗?我不明白那个变量来自哪里或它是指什么?我的意思是如果我分组4个不同的东西?我如何参考每一个?
var res = from archive in db.Archives
where archive.DateSent >= dateStartMonth &&
archive.DateSent < dateToday
group archive by archive.MyCode, archive.Extra into archiveGrp
select new
{
MyCode = archiveGrp.Key,
Extra = archiveGrp.??? …Run Code Online (Sandbox Code Playgroud) c# ×2
asp.net-core ×1
c++ ×1
curl ×1
iis ×1
json ×1
kestrel ×1
libcurl ×1
linq ×1
linq-to-sql ×1