小编Ian*_*ton的帖子

使用参数在MVVM Light中打开一个新窗口的最佳实践

我对mvvm和mvvm light很新,但我想我理解它的一般概念.我不明白的是,如果我想打开一个新窗口,但该窗口需要来自调用者的数据将这些数据传递到新窗口的最佳做法是什么?如果我将数据传递给构造函数,那么这意味着我需要在后面的代码中将代码传递给视图模型.我不能使用消息传递,因为它不是基本数据.提前致谢.

c# wpf mvvm mvvm-light

8
推荐指数
1
解决办法
7379
查看次数

Asp.net 5.0 MVC6 EF6迁移脚本

我正在使用Asp.net 5.0 mvc6,我想使用entityframework 6,因为7还没有完全编码,我已经能够让它做除了迁移之外的一切.

当我输入enable-migration,add-migration或update-datatabase时,我得到了

enable-migration : The term 'enable-migration' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of 
the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1
+ enable-migration
+ ~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (enable-migration:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException
Run Code Online (Sandbox Code Playgroud)

我很确定这些命令不在PowerShell中.但我确实发现%userdir%.dnx\packages\EntityFramework\_6.1.3\tools中有工具.稍微研究一下migrate.exe,我发现它们告诉我它只适用于proj文件,因此无法使用新设置.

我也尝试在dbcontext的构造函数中使用此代码进入编程路径,我有:

        var configuration = new MigrationConfiguration();
        var migrator = new DbMigrator(configuration);
        migrator.Configuration.TargetDatabase = new DbConnectionInfo(nameOrConnectionString, …
Run Code Online (Sandbox Code Playgroud)

powershell entity-framework-6 asp.net-core-mvc asp.net-core

8
推荐指数
1
解决办法
972
查看次数

通过Angular $ http而不是XMLHttpRequest呈现PDF

所以我花了几周时间研究如何通过ajax从服务器获取pdf,然后将其显示给客户端.我需要这样做的原因是用户不能直接在服务器上转到pdf,因为他们不会提供令牌来传递安全性,但我可以使用javascript.使用以下代码,我能够得到我所期望的:

 var xhr = new XMLHttpRequest();
 xhr.open('GET', url, true);
 xhr.responseType = 'arraybuffer';
 xhr.setRequestHeader("token", token.value);
 xhr.onload = function (e) {
    if (this.status == 200) {
       var file = new Blob([this.response], { type: 'application/pdf' });
       var fileURL = URL.createObjectURL(file);
       window.open(fileURL, '_blank');
    }
 };
 xhr.send();
Run Code Online (Sandbox Code Playgroud)

然而,当我尝试以这样的角度做这个确切的事情时(我正在做这个东西的一半,所以两者中的标题匹配):

var config = {
    url: url,
    method: 'GET',
    responseType: 'arraybuffer',
    headers: {
        'Accept':'*/*',
        "token": token.value
    }
}

$http(config)
    .success(function (response) {
        var file = new Blob([response], { type: 'application/pdf' });
        var fileURL = URL.createObjectURL(file);
        window.open(fileURL, '_blank')
    }); …
Run Code Online (Sandbox Code Playgroud)

javascript c# angularjs typescript

8
推荐指数
1
解决办法
875
查看次数