我正在尝试将Json发布到我们的Web服务.我的问题是,当我的request.ContentLength超过7kb时.我将在request.GetResponse()处获得Web异常500.但是如果我的request.ContentLength低于7kb,我的帖子就成功发送了.
错误信息:
The remote server returned an error: (500) Internal Server Error.
Run Code Online (Sandbox Code Playgroud)
源代码:
public static string JsonPost(string url, string method, string postData)
{
Uri address = new Uri(url + method);
HttpWebRequest request = WebRequest.Create(address) as HttpWebRequest;
request.Method = "POST";
request.ContentType = "application/json";
byte[] byteData = UTF8Encoding.UTF8.GetBytes(postData);
request.ContentLength = byteData.Length;
using (Stream postStream = request.GetRequestStream())
{
postStream.Write(byteData, 0, byteData.Length);
}
try
{
using (HttpWebResponse response = request.GetResponse() as HttpWebResponse)
{
StreamReader reader = new StreamReader(response.GetResponseStream());
string JsonResponse = reader.ReadToEnd();
return JsonResponse; …Run Code Online (Sandbox Code Playgroud) 解决了!!
我正在尝试创建我的应用程序的自定义URL协议,当他们访问或点击链接到myapp时启动我的应用程序:start
我的问题是如何知道用户安装我的应用程序的位置.在将HKEY_CLASSES_ROOT注册到注册表时,msi安装程序是否可以放置该位置?
HKEY_CLASSES_ROOT
myapp
(Default) = "URL:myapp Protocol"
URL Protocol = ""
DefaultIcon
(Default) = "myapp.exe,1"
shell
open
command
(Default) = "C:\Program Files\MyAppFolder\MyApp.exe" "%1"
Run Code Online (Sandbox Code Playgroud)
我想将路径"C:\ Program Files\MyAppFolder\MyApp.exe"更改为用户在安装过程中安装我的应用程序的位置.
解
HKEY_CLASSES_ROOT
myapp
(Default) = "URL:myapp Protocol"
URL Protocol = ""
DefaultIcon
(Default) = "myapp.exe,1"
shell
open
command
(Default) = "[TARGETDIR]MyApp.exe "%1""
Run Code Online (Sandbox Code Playgroud)
[TARGETDIR]将自动更改为用户安装文件的位置,例如"C:\ Program Files\MyAppFolder"
有关更多信息,请单击此链接 - > 将应用程序注册到URI方案
c# registry windows-installer visual-studio-setup url-protocol
有没有办法知道用户何时在C#windows窗体文本框中输入?
改写:有没有办法知道用户何时在C#windows窗体文本框上停止输入几秒钟(可能是5秒)?