小编Eri*_*ric的帖子

如何在knockout observablearray中通过索引访问对象?

我有一个可观察的数组:

var myObservableArray = ko.observableArray([
    { name: "Car", price: "9999" },
    { name: "Shoes", price: "20" },
    { name: "Paper", price: "1" }
]);
Run Code Online (Sandbox Code Playgroud)

我正在尝试访问数组中第一项的价格.

<div data-bind="text: myObservableArray()[0]"></div>
Run Code Online (Sandbox Code Playgroud)

显示:

[object Object]
Run Code Online (Sandbox Code Playgroud)

我试过了:

<div data-bind="text: myObservableArray()[0].price"></div>
Run Code Online (Sandbox Code Playgroud)

但这只是返回null.

这样做的正确语法是什么?

编辑:修复了下面指出的复制和粘贴错误.

knockout.js

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

为wsHttpBinding配置WCF

我有一个使用basicHttpBinding工作的WCF服务,我正在尝试将其配置为通过https并使用SQL成员资格提供程序进行身份验证,并且为此我尝试将其转换为使用wsHttpBinding.

但是,使用更新的配置,当我尝试连接客户端时出现以下错误:

无法在ServiceModel客户端配置部分中找到引用合同"KFileService.IKFileWcfService"的默认端点元素.这可能是因为没有为您的应用程序找到配置文件,或者因为在客户端元素中找不到与此合同匹配的端点元素.

这是服务器的web.config的相关部分:

<system.serviceModel>
    <protocolMapping>
      <remove scheme="http" />
      <add scheme="https" binding="wsHttpBinding" bindingConfiguration="wsHttpBinding_IKFileWcfServiceBinding" />
    </protocolMapping>
    <behaviors>
      <serviceBehaviors>
        <behavior name="KFileWcfServiceBehavior">
          <serviceMetadata httpGetEnabled="true" />
          <serviceDebug includeExceptionDetailInFaults="true" />
          <dataContractSerializer maxItemsInObjectGraph="2147483646" />
          <serviceCredentials>
            <userNameAuthentication userNamePasswordValidationMode="MembershipProvider"
              membershipProviderName="SqlMembershipProvider" />
          </serviceCredentials>
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <services>
      <service behaviorConfiguration="KFileWcfServiceBehavior" name="KFileWcfService">
        <endpoint address="https://localhost:36492/KFileWcfService.svc"
          binding="wsHttpBinding" bindingConfiguration="wsHttpBinding_IKFileWcfServiceBinding"
          name="wsHttpBinding_IKFileWcfService" bindingName="wsHttpBinding_IKFileWcfServiceBinding"
          contract="KFileWcfService.IKFileWcfService">
          <identity>
            <certificateReference storeLocation="CurrentUser" />
          </identity>
        </endpoint>
      </service>
    </services>
    <serviceHostingEnvironment minFreeMemoryPercentageToActivateService="0" multipleSiteBindingsEnabled="true"/>
    <bindings>
      <wsHttpBinding>
        <binding name="wsHttpBinding_IKFileWcfServiceBinding" maxBufferPoolSize="2147483647"
          maxReceivedMessageSize="2147483647">
          <readerQuotas maxDepth="32" maxStringContentLength="100000" maxArrayLength="2147483647"
            maxBytesPerRead="4096" maxNameTableCharCount="16384" />
          <security mode="Message">
          </security>
        </binding>
      </wsHttpBinding>
    </bindings>
</system.serviceModel>
Run Code Online (Sandbox Code Playgroud)

这是客户端: …

wcf wcf-binding wcf-security

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

标签 统计

knockout.js ×1

wcf ×1

wcf-binding ×1

wcf-security ×1