既然没有JavaScriptSerializer,可以用什么原生实现来处理这个问题?
我注意到JsonResult,我可以使用它将数据格式化为JSON,但是如何反序列化?
或许我错过了一些依赖关系project.json?
我很难在vNext项目中使用SignalR(epmty模板).
Firsty我将SignalR.Server依赖项添加到我的project.json文件中,它现在看起来像这样:
{
"webroot": ".",
"dependencies": {
"Microsoft.AspNet.Server.IIS": "1.0.0-beta3",
"Microsoft.AspNet.Server.WebListener": "1.0.0-*",
"Microsoft.AspNet.StaticFiles": "1.0.0-*",
"Microsoft.AspNet.SignalR.Server": "3.0.0-*",
"Serilog": "1.4.113.0"
},
"commands": {
"web": "Microsoft.AspNet.Hosting server=Microsoft.AspNet.Server.WebListener server.urls=http://localhost:5002"
},
"frameworks": {
"dnx451": {
"dependencies": {
"Microsoft.Framework.Logging.Serilog": "1.0.0-*"
}
},
"dnxcore50": { }
}
}
Run Code Online (Sandbox Code Playgroud)
然后我想在我的Startup.cs中映射SignalR(因为我发现在git上的somwhere)
public void ConfigureServices(IServiceCollection services)
{
services.AddSignalR(options =>
{
options.Hubs.EnableDetailedErrors = true;
});
}
public void Configure(IApplicationBuilder app, ILoggerFactory loggerFactory)
{
#if DNX451
string OutputTemplate = "{SourceContext} {Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz} [{Level}] {Message}{NewLine}{Exception}";
var serilog = new LoggerConfiguration()
.MinimumLevel.Verbose()
.WriteTo.RollingFile(@".\SignalR-Log-{Date}.txt", outputTemplate: …Run Code Online (Sandbox Code Playgroud) 嗨,我有获取jstree模型的选定节点的数据的问题.
<script type="text/javascript">
$('#preview').on("changed.jstree", function (e, data) {
console.log(data.selected);
console.log(data.selected.attr("text"));
});
</script>
Run Code Online (Sandbox Code Playgroud)
第一个控制台日志显示"[js1_1]"或"[js1_2]",具体取决于所选节点.但第二个日志"未定义不是一个函数"; /我尝试了很多不同的方法,但我没有获得节点文本(标题)或任何其他信息
我发送模型列表作为json,它看起来像这样:
Public Class JsTreeModel
Public Property text As String
Public Property icon As String
Public Property Id As String
Public Property PId As String
Public Property ParentId As String
Public Property Status As Integer
End Class
Run Code Online (Sandbox Code Playgroud)
谁有解决方案?
更新jstree代码
<script type="text/javascript">
$(document).ready(function () {
$('#WhenRemoving').toggle($('.RemoveCheckbox').is(":checked"));
$('#WhenAdding').toggle(!$('.RemoveCheckbox').is(":checked"));
$('#preview').jstree({
'core': {
'data': {
'url': '/TreeTest/TreePreview/',
'data': function (node) {
return node;
}
}
}
}).bind("loaded.jstree", function (event, data) { …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用signalr将数据存储在asp.net应用程序中.在这里说明我的问题是一个例子.
我有一个集线器,通知控件用户已连接并发送他的ID.
public static event EventHandler<IdEventArgs> userConnected;
public void Connected()
{
Debug.WriteLine("Hub Connected Method");
var id = Context.ConnectionId;
userConnected(this, new IdEventArgs(id));
}
Run Code Online (Sandbox Code Playgroud)
然后我有我的控制器将事件处理程序添加到集线器
public ActionResult Index()
{
LoadingHub.userConnected += new EventHandler<IdEventArgs>(UserConnected);
return View();
}
Run Code Online (Sandbox Code Playgroud)
最后我的方法应该保存获取的数据
private void UserConnected(object sender, IdEventArgs e)
{
Debug.WriteLine("User Connected with Id: " + e.Id);
//To do:
//save data
}
Run Code Online (Sandbox Code Playgroud)
我尝试保存到Session,但Session对象在这里为null.我遇到了用户配置文件,这可能是一个很好的解决方案 - 当用户连接到内部存储数据时,是否可以创建新的配置文件,当他断开连接以销毁所述配置文件时?或者也许完全不同的方法在这里更容易理解?
我一直在尝试编写后台任务,将原始推送通知显示为吐司.当应用程序运行时,我得到推送通知.
This is my background task class:
public sealed class BackgroundNotificationsTask : IBackgroundTask
{
public void Run(IBackgroundTaskInstance taskInstance)
{
RawNotification notification = (RawNotification)taskInstance.TriggerDetails;
string content = notification.Content;
Debug.WriteLine("Background raw notification obtained!");
//SendNotification(content);
}
private void SendNotification(string text)
{
XmlDocument toastXml = ToastNotificationManager.GetTemplateContent(ToastTemplateType.ToastText01);
XmlNodeList elements = toastXml.GetElementsByTagName("text");
foreach (IXmlNode node in elements)
{
node.InnerText = text;
}
ToastNotification notification = new ToastNotification(toastXml);
ToastNotificationManager.CreateToastNotifier().Show(notification);
}
}
Run Code Online (Sandbox Code Playgroud)
Then I Register In MainPage.xaml.cs
private void RegisterTasks()
{
BackgroundAccessStatus status = await BackgroundExecutionManager.RequestAccessAsync();
var taskRegistered …Run Code Online (Sandbox Code Playgroud) c# ×4
asp.net ×2
asp.net-core ×2
jquery ×1
json ×1
jstree ×1
signalr ×1
signalr-hub ×1
winrt-xaml ×1