小编Jak*_*ski的帖子

ASP.Net Core中的JSON序列化/反序列化

既然没有JavaScriptSerializer,可以用什么原生实现来处理这个问题?

我注意到JsonResult,我可以使用它将数据格式化为JSON,但是如何反序列化?

或许我错过了一些依赖关系project.json

c# json asp.net-core

114
推荐指数
2
解决办法
14万
查看次数

SignalR with vNext

我很难在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)

c# asp.net signalr asp.net-core

6
推荐指数
1
解决办法
4902
查看次数

获取选定的Jstree节点值JQuery

嗨,我有获取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)

jquery jstree

4
推荐指数
1
解决办法
3万
查看次数

使用signalr在asp.net中存储数据

我正在尝试使用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.我遇到了用户配置文件,这可能是一个很好的解决方案 - 当用户连接到内部存储数据时,是否可以创建新的配置文件,当他断开连接以销毁所述配置文件时?或者也许完全不同的方法在这里更容易理解?

c# asp.net signalr-hub

3
推荐指数
1
解决办法
1815
查看次数

应用程序未运行Windows Phone 8.1时的RawPushNotification

我一直在尝试编写后台任务,将原始推送通知显示为吐司.当应用程序运行时,我得到推送通知.

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# winrt-xaml windows-phone-8.1

0
推荐指数
1
解决办法
1036
查看次数