我试图从客户端传输一个字符串到ASP.NET MVC4应用程序.
但我无法接收字符串,无论是null还是找不到post方法(404错误)
客户端代码传输字符串(控制台应用程序):
HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://localhost:49032/api/test");
request.Credentials = new NetworkCredential("user", "pw");
request.Method = "POST";
string postData = "Short test...";
byte[] byteArray = Encoding.UTF8.GetBytes(postData);
request.ContentType = "application/x-www-form-urlencoded";
request.ContentLength = byteArray.Length;
Stream dataStream = request.GetRequestStream();
dataStream.Write(byteArray, 0, byteArray.Length);
dataStream.Close();
WebResponse response = request.GetResponse();
Console.WriteLine(((HttpWebResponse)response).StatusDescription);
dataStream = response.GetResponseStream();
StreamReader reader = new StreamReader(dataStream);
string responseFromServer = reader.ReadToEnd();
Console.WriteLine(responseFromServer);
reader.Close();
dataStream.Close();
response.Close();
Console.ReadLine();
Run Code Online (Sandbox Code Playgroud)
ASP.NET Web Api控制器:
public class TestController : ApiController
{
[Authorize]
public String Post(byte[] value)
{
return value.Length.ToString();
}
} …Run Code Online (Sandbox Code Playgroud) 如何在我的类(库中)中为intellisense提供我创建的XML注释?
我已经为每个方法添加了XML注释,如:
/// <summary>
/// Do some connection request...
/// </summary>
/// <param name="val">Required for xyz...</param>
public void Connect(int val)
{
// Some code...
}
Run Code Online (Sandbox Code Playgroud)
然后我标记了创建"XML文档文件"的复选框,并为其命名为"MyAssembly.xml".重建我的解决方案(创建一个dll和一个XML文件).将dll添加到另一个c#项目中,但是intellisense没有显示我的XML注释...我做错了什么?
在Netbeans 7.0/7.1中是否有可用于JavaFX2的GUI构建器?在之前的Netbeans版本中,我使用了插件"JavaFX Composer",但似乎该插件不适用于7.0和7.1.
你有什么建议吗?
谢谢
我非常绝望....让我的WPF分组列表视图工作......我无法在列表视图中滚动...
在我的示例应用程序中,我有一个带有两个扩展器的Listview.第一个包含很多listviewitems ...所以滚动是必要的...但是如果我使用"该死的滚动条"它会直接跳转到下一个扩展器(在我的情况下是扩展器2of2)...所以它是不可能的正确滚动...
第一个截图:

第二个截图:

我的ListView风格:
<Style x:Key="list12" TargetType="ListView">
<Setter Property="SnapsToDevicePixels" Value="true"/>
<Setter Property="OverridesDefaultStyle" Value="true"/>
<Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Auto"/>
<Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Auto"/>
<Setter Property="ScrollViewer.CanContentScroll" Value="true"/>
<Setter Property="VerticalContentAlignment" Value="Center"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="ListView">
<Border Name="Border" BorderThickness="1" BorderBrush="#999999" Background="#DFDFDF">
<ScrollViewer Style="{DynamicResource {x:Static GridView.GridViewScrollViewerStyleKey}}">
<ItemsPresenter />
</ScrollViewer>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
Run Code Online (Sandbox Code Playgroud)
我的GridView.GridViewScrollViewerStyle:
<Style x:Key="{x:Static GridView.GridViewScrollViewerStyleKey}" TargetType="ScrollViewer">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="ScrollViewer">
<Grid Background="{TemplateBinding Background}">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<DockPanel Margin="{TemplateBinding Padding}">
<ScrollViewer DockPanel.Dock="Top" HorizontalScrollBarVisibility="Hidden" …Run Code Online (Sandbox Code Playgroud) 我想在长期操作完成后返回一些值.但此外,我想分裂逻辑和gui.
例如; 我有两节课
所以,以前在Objective-C中我只是在SomeServices中添加一个方法,如下所示:
(void)getDataFromService:(void (^)(NSArray *, NSError *))completionBlock{ ...... }
Run Code Online (Sandbox Code Playgroud)
在这个方法中,我只是调用completionBlock(myData, myError)将我的值返回到tableviewcontroller.
我必须在SomeServices.swift中定义的等效闭包是什么以及如何在MyTableViewController中调用它?
我知道如何调用这样的简单闭包:
....({
responseData, error in
if(!error){
//Do something
}
})
Run Code Online (Sandbox Code Playgroud)
但我没有任何想法如何定义一个与completionBlock等效的闭包.
任何帮助,将不胜感激
有没有办法在生成(C#)时观察"应用程序和服务"的事件?我发现我不能使用WMI.
还有其他想法吗?
我有以下存储过程:
ALTER PROCEDURE [dbo].[CheckAdminExists]
@SID NVARCHAR(50),
@AdminName NVARCHAR(MAX)
AS
SELECT
Administrator.ID
FROM
Administrator
WHERE
Administrator.SID = @SID
AND Administrator.Name = @AdminName
GO
Run Code Online (Sandbox Code Playgroud)
现在我想用这样的代码创建另一个SP:
IF NOT NULL (EXECUTE CheckAdminExists 'S-1','Admin')
--do something
ELSE
--do something else
Run Code Online (Sandbox Code Playgroud)
这样做的正确语法是什么?
有谁知道一个简单的XAML解决方案来改变整个背景ToolTip?
我做了以下事情:
<Image Height="16" Source="Images/Icons/Add2.png" Stretch="Fill" Width="16" Opacity="0.99" Grid.Column="0">
<Image.ToolTip>
<Grid Background="#000000">
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition />
</Grid.RowDefinitions>
<TextBlock Text="Header1" FontSize="15" Grid.Row="0"/>
<TextBlock Text="Subitem" FontSize="12" Grid.Row="1"/>
</Grid>
</Image.ToolTip>
</Image>
Run Code Online (Sandbox Code Playgroud)
但结果看起来像这样:

有什么建议?
我在C#中解析我的XML文件(RSS Feed)时遇到问题.我只是想读出"条目"条目(根父母 - "饲料" - 不相关).所有"条目"条目几乎是均匀的,除了"州"部分.有些条目没有该条目.
所以我只想读出以下内容:"入口"节点:
有什么建议?非常感谢你.
<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
<updated>2011-01-01T00:00:00+0100</updated>
<link href="http://www.domain.com" rel="self"/>
<author>
<name>Mr X</name>
<email>Mr_X@domain.com</email>
</author>
<title>Some infos....</title>
<id>domain.com</id>
<entry>
<updated>2011-01-01T00:00:00Z</updated>
<expires>2011-01-02T00:00:00Z</expires>
<title>My first Title</title>
<id>First ID</id>
<link type="text/html" rel="alternate"
href="http://domain.com/firstElement"></link>
<summary>My first important summary</summary>
<rights>domain.com</rights>
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<div>
<img alt="second" width="32"
src="http://domain.com/firstElement.png"/>
</div>
</div>
</content>
</entry>
<entry>
<updated>2011-01-01T00:00:00Z</updated>
<expires>2011-01-02T00:00:00Z</expires>
<title>My second Title</title>
<state>active</state>
<id>Second ID</id>
<link type="text/html" rel="alternate"
href="http://domain.com/secondElement"></link>
<summary>My second important summary</summary>
<rights>domain.com</rights>
<content type="xhtml"> …Run Code Online (Sandbox Code Playgroud) 我正在尝试根据列表视图项目数据执行方法。除此之外,触发命令的按钮应该只在列表视图项的“CanExecute”方法返回 true 时启用。
“MyCommand”和“CanExecute”这两种方法都包含在我的 ViewModel 中。不幸的是,我不确定如何将项目信息正确地传递给这两种方法以符合 PRISM 6 框架。
所以我的第一种方法是这样做:
模型
public class MyModel
{
public string Name { get; set; }
public string Version { get; set; }
public int Identifier { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
视图模型
public class MyViewModel : BindableBase
{
private ObservableCollection<MyModel> _models = new ObservableCollection<MyModel>();
public ObservableCollection<MyModel> Models
{
get { return _models; }
set { SetProperty(ref _models, value); }
}
public DelegateCommand VerifyCommand { get; set; }
public MyViewModel()
{
//Add test data
for …Run Code Online (Sandbox Code Playgroud) c# ×6
wpf ×2
.net-4.0 ×1
asp.net ×1
asp.net-mvc ×1
background ×1
database ×1
event-log ×1
grouping ×1
intellisense ×1
ios8 ×1
javafx ×1
listview ×1
mvvm ×1
netbeans ×1
netbeans-7.1 ×1
parsing ×1
post ×1
prism ×1
scrollbar ×1
sql ×1
sql-server ×1
swift ×1
t-sql ×1
tooltip ×1
windows ×1
xaml ×1
xml ×1