我试图通过使用REST,WCF和JSON(所有这些技术的新手)来使我的应用程序正常工作.我让'GET'正常工作.正是"POST"导致了我的问题.
正如您将在下面看到的那样,我使用JSON.stringify打包'我的JSON,然后将POST发送到REST资源.但是,当对象到达处理请求的WCF方法时,该对象始终为null.
这是代码:
$.ajax({
type: "POST",
dataType: "json",
url: "Services/ContactCompanyService.svc/contactcompanies/customers",
contentType: "application/json; charset=utf-8",
data: JSON.stringify({ contactcompany: newCustomer }),
success: function (html) { alert(html); }
});
Run Code Online (Sandbox Code Playgroud)
这是配置的东西:
<services>
<service behaviorConfiguration="ServiceBehaviour" name="ContactCompanyService">
<endpoint address="contactcompanies" behaviorConfiguration="web" binding="webHttpBinding" contract="IContactCompanyService"/>
</service>
</services>
<behaviors>
<endpointBehaviors>
<behavior name="web">
<webHttp/>
<enableWebScript/>
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior name="ServiceBehaviour">
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
<behavior name="">
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" aspNetCompatibilityEnabled="true"/>
Run Code Online (Sandbox Code Playgroud)
这是合同:
[OperationContract]
[WebInvoke(Method = "POST", RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Wrapped, UriTemplate …Run Code Online (Sandbox Code Playgroud) 我在 WPF 中使用 ListView 时遇到性能非常差的情况,使用大约 30000 条记录。据我所知,虚拟化应该打开,因为这是默认设置(我什至在 XAML 中显式打开它)。
表现不佳的表现是这样的:
我希望有人能看一下 XAML 并让我有一些想法。
<ListView Name="grdComms" Grid.Row="0" Grid.Column="0" SelectedItem="{Binding SelectedHeader}"
VirtualizingStackPanel.IsVirtualizing="True" VirtualizingStackPanel.VirtualizationMode="Recycling"
ScrollViewer.IsDeferredScrollingEnabled="True">
<ListView.View>
<GridView >
<GridViewColumn Header="Account Name" DisplayMemberBinding="{Binding Path=AccountName}" Width="150" />
<GridViewColumn Header="Account Number" DisplayMemberBinding="{Binding Path=AccountNumber}" Width="120" />
<GridViewColumn Header="Type" DisplayMemberBinding="{Binding Path=Type}" Width="80" />
<GridViewColumn Header="Delivery" DisplayMemberBinding="{Binding Path=Delivery}" Width="80" />
<GridViewColumn Header="Count" DisplayMemberBinding="{Binding Path=RequestCount}" Width="80" />
<GridViewColumn Width="80" Header="DeDupe">
<GridViewColumn.CellTemplate>
<DataTemplate>
<StackPanel Width="80">
<CheckBox HorizontalAlignment="Center" IsChecked="{Binding Path=SelectedForProcessing, Mode=TwoWay}"/>
</StackPanel>
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
</GridView>
</ListView.View>
</ListView>
Run Code Online (Sandbox Code Playgroud)
注意:ItemsSource …