小编har*_*ang的帖子

远程验证OnBlur和空字符串

我有一个启用了远程验证的视图模型.在我看来,我也禁用了OnKeyUp

    $(function() {
        $.validator.setDefaults({ onkeyup: false });
    })
Run Code Online (Sandbox Code Playgroud)

但是,如果我专注于文本框,并将焦点移动到另一个控件,则根本不会触发远程验证.

当我将它配置为onBlur和空字符串时,有没有办法可以让远程验证触发?

asp.net-mvc remote-validation asp.net-mvc-4

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

Pvk2Pfx不会使用输入PVK密码进行输出PFX保护

我正在使用Pvk2Pfx将pvk和cer转换为pfx文件,我使用的命令是

pvk2pfx -pvk MyTest.pvk -spc MyTest.cer -pfx MyTest.pfx
Run Code Online (Sandbox Code Playgroud)

在使用pvk文件创建过程中makecert,我被提示输入私钥密码.

当我运行转换命令时,还提示我输入pvk文件的密码.当我尝试将pfx文件导入Windows中的证书存储区时,我不必指定密码.但根据微软的文件

/ po pfxpassword指定.pfx文件的密码.如果未指定.pfx文件的密码,则.pfx文件的密码将与.pvk文件的密码相同

在这种情况下我没有在我的命令中使用/ po开关,我认为pfx文件应该具有相同的pvk文件密码,对吧?为什么我不需要提供密码才能将其导入证书库?

x509certificate

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

PowerShell 导入 Pfx 和私钥“丢失”

我使用以下 PowerShell 函数将 PFX 导入到我的 Windows 2008 R2 服务器的证书存储中

function Import-PfxCertificate ([String]$certPath,[String]$certificateStoreLocation = "CurrentUser",[String]$certificateStoreName = "My",$pfxPassword = $null)
{
    $pfx = new-object System.Security.Cryptography.X509Certificates.X509Certificate2    

    $pfx.Import($certPath, $pfxPassword, "Exportable,PersistKeySet")    

    $store = new-object System.Security.Cryptography.X509Certificates.X509Store($certificateStoreName,$certificateStoreLocation)    
    $store.open("MaxAllowed")    
    $store.add($pfx)    
    $store.close()
    return $pfx
}
Run Code Online (Sandbox Code Playgroud)

该函数的调用者看起来像$importedPfxCert = Import-PfxCertificate $pfxFile "LocalMachine" "My" $password我将它安装到本地机器的我的商店。然后我向我的 IIS 应用程序池授予了读取权限。

我有一个需要使用它的 WCF 服务

<behaviors>
  <serviceBehaviors>
    <behavior>
      <serviceCredentials>
        <serviceCertificate findValue="MyCertName" x509FindType="FindBySubjectName" />
        <userNameAuthentication userNamePasswordValidationMode="Custom"
          customUserNamePasswordValidatorType="MyValidator" />
      </serviceCredentials>
    </behavior>
  </serviceBehaviors>
</behaviors>
Run Code Online (Sandbox Code Playgroud)

当我使用客户端调用服务时,WCF 出现异常 It is likely that certificate 'CN=MyCertName' may not have a private key …

powershell-2.0 x509certificate

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

启用Nuget包还原时出现奇怪的Nuget错误

我右键单击我的VS2010中的解决方案文件并单击Enable NuGet Package Restore,我收到一条错误消息说Unable to read package from path 'NuGet.CommandLine.2.7.1.nupkg'.

我用Google搜索,看不到任何接近的东西.

任何线索?

visual-studio-2010 nuget

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

依赖注入和运行时构造函数参数

我将使用一个非常简单的例子来描述我的问题。假设我有一个类来处理数据库调用

public class DatabaseAccessLayer : IDatabaseAccessLayer
{
    public DatabaseAccessLayer(string uid, string password, string server)
    {
        // build connection object and so on
    }
}
Run Code Online (Sandbox Code Playgroud)

然后我有一个类来使用它

public class MyBusinessService : IBusinessService
{
    public MyBusinessService(IDatabaseAccessLayer dal)
    {
    }
}
Run Code Online (Sandbox Code Playgroud)

如果以我Unity为例,我通常会以这种方式连接 IoC 容器

container.RegisterType<IDatabaseAccessLayer, DatabaseAccessLayer>(new InjectionConstructor("my_uid", "my_password", "my_server"));
container.RegisterType<IBusinessService, MyBusinessService>();
Run Code Online (Sandbox Code Playgroud)

如果在应用程序启动时设置 IoC 容器时将参数定义为已知值,则效果很好,例如典型的 Web 应用程序在配置文件中具有这些值。

但是,有一个要求是我必须将参数(uid、密码、服务器)传递给每个业务服务调用的数据访问层类,因为每次的值都可能不同。在这种情况下,我似乎无法使用 IoC 容器。

任何人都有一些评论,在这种情况下我应该放弃IoC容器还是有更好的方法来使用IoC容器?

c# dependency-injection

6
推荐指数
0
解决办法
777
查看次数

Angular 静态 Base URl 和使用 useHash=True 的路由

我正在使用 Angular 6,我希望我的应用程序有一个静态基本 URL,以便进行反向代理配置。

在我的index.html我设置基本网址

<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <title>APM</title>
  <base href="/my-base">

  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="icon" type="image/x-icon" href="favicon.ico">
</head>
<body>
  <pm-root></pm-root>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)

在我的app.module.ts我配置了路由表

import { BrowserModule } from '@angular/platform-browser';
import { FormsModule } from '@angular/forms';
import { HttpClientModule } from '@angular/common/http';
import { NgModule } from '@angular/core';
import { RouterModule } from '@angular/router';

import { AppComponent } from './app.component';
import { WelcomeComponent } from './home/welcome.component';

@NgModule({
  declarations: [
    AppComponent,
    WelcomeComponent …
Run Code Online (Sandbox Code Playgroud)

angular-ui-router angular

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

$("#MyForm").submit(function(){在IE8中不起作用但FireFox 8不起作用?

$(document).ready(function () {
    $("#MyForm").submit(function () {
        alert("Hello");
        return true;
    });
});
Run Code Online (Sandbox Code Playgroud)

嗨,我上面有一个非常简单的代码,当我在IE8中提交表单时没有任何反应,但它在FireFox 8中工作正常.

我正在使用jQuery 1.5.1.这是旧版jQuery的问题吗?

jquery

5
推荐指数
1
解决办法
3230
查看次数

UserPrincipal.FindByIdentity在IIS服务器上返回null

我在ASP.NET中有以下代码示例

        using (PrincipalContext domainContext = new PrincipalContext(ContextType.Domain))
        {
            using (UserPrincipal user = UserPrincipal.FindByIdentity(domainContext, HttpContext.Current.User.Identity.Name))
            {
                if (user == null)
                {
                    lbName.Text = "No User Principal";
                }
                else
                {
                    lbName.Text = user.DisplayName;
                }
            }
        }
Run Code Online (Sandbox Code Playgroud)

web.config看起来像

<authentication mode="Windows" />
<authorization>
  <deny users="?" />
</authorization>
Run Code Online (Sandbox Code Playgroud)

我尝试在我的本地开发机器上的代码(域的一部分,登录域用户,VS2010,.Net 4.0,Windowx XP)进行本地测试,我能够得到UserPrincipal对象.

如果我部署到WIndows 2003(也是域的一部分),IIS6,.Net 4.0,在网络服务下运行应用程序池,我关闭了匿名访问.但代码无法获得UserPrincipal对象.

我是否必须更改应用程序池以在域帐户下运行才能获得UserPrincipal

asp.net directoryservices

5
推荐指数
1
解决办法
5632
查看次数

使用PowerShell授予IIS 7.5应用程序池读取证书私钥的权限

我四处搜索,找不到很多信息,基本上我有Windows 2008 R2,我创建了PowerShell脚本,将PFX文件加载到Local Machine的证书存储区.

现在,我需要授予应用程序池的权限,以便使用PowerShell读取证书的私钥.

在Windows 2003的旧方式中,我只需要将实际文件放在C:\ProgramData\Microsoft\Crypto\RSA\MachineKeys\文件夹中,但看起来Win 2008使用的是另一个文件夹.

有人有解决方案吗?

- 更新我的代码版本 -

function Grant-CertificatePermissions([string]$certSubject,[string]$user,[string]$permissionType,[string]$permission = $args[3])
{
    $getCert = Get-LocalMachineCertificate $certSubject
    $keypath = Get-CertificateStorePath
    $certHash = $getCert.PrivateKey.CspKeyContainerInfo.UniqueKeyContainerName
    $certFullPath = $keypath+$certHash
    $certAcl = Get-Acl -Path $certFullPath

    try
    {
        $accessRule=new-object System.Security.AccessControl.FileSystemAccessRule $user, $permissionType, $permission
        $certAcl.AddAccessRule($accessRule)
    }
    catch [System.Exception]
    {
        throw "Invalid User Id Or Permission"
    }
    Set-Acl $certFullPath $certAcl
}

function Get-LocalMachineCertificate([string]$subject, [string]$certificateStoreLocation, [string]$certificateStoreName)
{
    $getCert = Get-ChildItem -Recurse Cert:\$certificateStoreLocation\$certificateStoreName | Where-Object {$_.Subject -eq $subject}

    if(!$getCert)
    {
        throw "Certificate Not …
Run Code Online (Sandbox Code Playgroud)

powershell certificate iis-7.5

5
推荐指数
1
解决办法
5707
查看次数

如何正确使用Nest.js的@Headers?

根据控制器文档,我可以使用@Headers(param?: string)req.headersreq.headers[param]获取标头值。我尝试了第一种方法,在Postman的请求标头中有以下内容

Content-Type:application/json
My-Id:test12345
Run Code Online (Sandbox Code Playgroud)

我有以下控制器示例代码

@Put('/aa/:aa/bb/:bb/')
@UsePipes(new ValidationPipe({ transform: true }))
public async DoMyJob(@Body() request: MyRequestDto,
                                @Param('aa') aa: number,
                                @Param('bb') bb: string,
                                @Headers('My-Id') id: string): Promise<MyResponseDto> {
    // More code here
}
Run Code Online (Sandbox Code Playgroud)

当我设置断点以检查My-Id标题中的值时,它是未定义的。

那么,如何正确地在Nest.Js中从RESTful服务客户端获取标头值?

http-headers node.js nestjs

5
推荐指数
1
解决办法
1716
查看次数