我想在我的mvc项目中使用ReadAsAsync()和.net 4.0.结果为null.
如果我输入uri到地址栏,则chrome的结果为(标签名称已更改):
<ns2:MyListResponse xmlns:ns2="blablabla">
<customerSessionId>xxcustomerSessionIdxx</customerSessionId>
<numberOfRecordsRequested>0</numberOfRecordsRequested>
<moreResultsAvailable>false</moreResultsAvailable>
<MyList size="1" activePropertyCount="1">
<MySummary order="0">
<id>1234</id>
<name>...</name>
.
.
</MySummary>
</MyList>
</ns2:MyListResponse>
Run Code Online (Sandbox Code Playgroud)
如果我在代码中使用该语句:
using (var client = new HttpClient())
{
var response = client.GetAsync(apiUri).Result;
var message = response.Content.ReadAsStringAsync().Result;
var result1 = JsonConvert.DeserializeObject<MyListResponse>(message);
var result2 = response.Content.ReadAsAsync<MyListResponse>().Result;
}
Run Code Online (Sandbox Code Playgroud)
消息以字符串格式出现"{\"MyListResponse\":{\"customerSessionId\"...}",对应于json对象:
{"MyListResponse":
{"customerSessionId":"xxcustomerSessionIdxx",
"numberOfRecordsRequested":0,
"moreResultsAvailable":false,
"MyList":
{"@size":"1",
"@activePropertyCount":"1",
"MySummary":
{"@order":"0",
"id":1234,
"name":"...",
.
.
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
并且result1和result2的属性为null或默认值.类定义如下.我想将内容作为对象阅读,但我不能.您有什么建议来解决这个问题?我究竟做错了什么?提前致谢.
public class MySummary
{
public int @Order { get; set; }
public string …Run Code Online (Sandbox Code Playgroud) 我必须使用条件where子句,如下所示,该子句的工作版本是什么?
AND CASE WHEN b.kurum_turu = 1
THEN u.kod in ('1125', '2975', '1127', '4460', '1128', '1126')
ELSE u.kod in ('1125', '2975')
END
Run Code Online (Sandbox Code Playgroud) 我已经将umbracoCms((版本7.5.4))nuget包安装到我的空mvc项目(.Net 4.6.2,vs2015).然后,我运行项目并打开安装页面.然后我自定义连接并使用连接字符串为ms sql 2016数据库.我没有选择任何入门网站,我有以下错误:
The database failed to upgrade. ERROR: The database configuration failed with the following message: Invalid object name 'cmsContent'. Please check log file for additional information (can be found in '/App_Data/Logs/UmbracoTraceLog.txt')
Run Code Online (Sandbox Code Playgroud)
我现在应该怎么做 ?
安装步骤:
1-
2-点击自定义后:
3-为数据库类型选择"自定义连接字符串"后:
点击"不,谢谢,我不想安装入门网站"链接后出现5-完全错误:
2016-11-28 22:31:20,810 [P1436/D4/T19] ERROR Umbraco.Core.Persistence.UmbracoDatabase - Database exception occurred
System.Data.SqlClient.SqlException (0x80131904): Invalid object name 'cmsContent'.
at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)
at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)
at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose)
at System.Data.SqlClient.TdsParser.TryRun(RunBehavior …Run Code Online (Sandbox Code Playgroud) function girisAjaxKontrol() {
var kullanici = { 'kullaniciAdi': $('#username').val(), 'hidden': $('#password').val() };
$.ajax({
url: '/Giris/GirisGecerliMi',
type: 'POST',
data: kullanici,
success: girisAjaxReturn,
error: function (error, textstatus) {
JSON.stringify(error);
errorMessage($("div.girisSubmit input"), JSON.stringify(error), false);
}
});
Run Code Online (Sandbox Code Playgroud)
}
此函数会收到以下错误(它在部署之前正在运行).该网站是本地IIS 7.5上的Asp .Net MVC4网站; 我搜索了很多,但还没解决.
Server Error in Application \"DEFAULT WEB SITE\"
HTTP Error 404.0 - Not Found
The resource you are looking for has been removed, had its name changed, or is temporarily unavailable.
Module: IIS Web Core
Notification: MapRequestHandler
Handler: StaticFile
Error Code: 0x80070002 …Run Code Online (Sandbox Code Playgroud) 我有参数发送像
@Html.Action("actionName", "controlName", new{ pName1 = "pValue1", ... })
但是,pName1 = "pValue1", ...将来自控制器的ViewBag.应该用ViewBag封装的对象类型,以及如何将路由值设置为Html.Action?
下面的代码在Nest 6.0枚举动态匹配结果之前已经可以使用。但是它抛出InvalidCastException了。
码:
var response = elasticClient.Search<dynamic>(
s => s.Query(q => q.QueryString(m => m.Query(elasticQueryModel.QueryString))
).Source(src => src.Includes(f => f.Fields(fields))).Size(querySize).AllTypes().Index(elasticQueryModel.Index));
var hits = response.Hits;
var rows = new List<Dictionary<string, object>>();
foreach (var hit in hits)
{
var source = (IDictionary<string, Newtonsoft.Json.Linq.JToken>)hit.Source;
var row = new Dictionary<string, object>();
foreach (var keyValuePair in source)
{
row[keyValuePair.Key] = keyValuePair.Value;
}
rows.Add(row);
}
Run Code Online (Sandbox Code Playgroud)
什么是hit.Source的有效转换,或此代码块的另一种解决方案?
c# ×3
.net-4.0 ×1
ajax ×1
asp.net-mvc ×1
conditional ×1
datetime ×1
enumeration ×1
html-helper ×1
httpclient ×1
installation ×1
nest ×1
nuget ×1
oracle ×1
sql ×1
umbraco ×1
umbraco7 ×1
where-clause ×1