这里/// /// post登录 /// public void SendLogin(string loginUrl, string postData
/// post登录
///
public void SendLogin(string loginUrl, string postData)
{
byte[] byteArray = Encoding.GetEncoding(“GBK”).GetBytes(postData);
try
{
//基于apache服务器,IIS发布的则不需要
ServicePointManager.Expect100Continue = false;
CookieContainer cookieContainer = new CookieContainer();
//创建对url的请求
httpWebRequest = (HttpWebRequest)WebRequest.Create(loginUrl);
httpWebRequest.CookieContainer = cookieContainer;
httpWebRequest.Accept = “image/gif, image/jpeg, image/pjpeg, image/pjpeg, application/x-shockwave-flash, application/xaml+xml, application/x-ms-xbap, application/x-ms-application, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, /”;
httpWebRequest.Headers[“Accept-Language”] = “zh-cn”;
httpWebRequest.UserAgent = “Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; EmbeddedWB 14.52 from: http://www.bsalsa.com/ EmbeddedWB 14.52; .NET4.0C; .NET4.0E; .NET CLR 2.0.50727; .NET CLR 3.0.04506.648; .NET CLR 3.5.21022; InfoPath.2)”;
httpWebRequest.ContentType = “application/x-www-form-urlencoded”;
//协议方式
httpWebRequest.Method = “POST”;
//post开始
//请求内容长度
httpWebRequest.ContentLength = byteArray.Length;
Stream dataStream = httpWebRequest.GetRequestStream();
// 请求数据放入请求流
dataStream.Write(byteArray, 0, byteArray.Length);
dataStream.Close();
//返回html
httpWebResponse = (HttpWebResponse)httpWebRequest.GetResponse();
if (httpWebResponse.StatusCode == HttpStatusCode.OK)
{
StreamReader reader = new StreamReader(httpWebResponse.GetResponseStream(), Encoding.GetEncoding("GBK"));
//读取响应流
string responseFromServer = reader.ReadToEnd();
reader.Close();
dataStream.Close();
httpWebResponse.Close();
if (responseFromServer.IndexOf("登录用户名") > 0)
{
TxtInfo.Text = "登录成功";
//保存cookie
gCookieCollention = httpWebResponse.Cookies;
TxtUid.IsEnabled = false;
TxtPwd.IsEnabled = false;
LblName.Content = "使用者:" + TxtUid.Text;
}
else
{
TxtInfo.Text = responseFromServer;
}
}
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
}
发帖
///
/// post帖子
///
public void SendInfo(string infoUrl, string postData)
{
byte[] byteArray = Encoding.GetEncoding(“GBK”).GetBytes(postData);
try
{
CookieContainer cookieContainer = new CookieContainer();
//发出对url的请求
httpWebRequest = (HttpWebRequest)WebRequest.Create(infoUrl);
//得到cookie
httpWebRequest.CookieContainer = cookieContainer;
httpWebRequest.CookieContainer.Add(gCookieCollention);
httpWebRequest.ContentType = "application/x-www-form-urlencoded";
httpWebRequest.Accept = "image/gif, image/jpeg, image/pjpeg, image/pjpeg, application/x-shockwave-flash, application/xaml+xml, application/x-ms-xbap, application/x-ms-application, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, */*";
httpWebRequest.Headers["Accept-Language"] = "zh-cn";
httpWebRequest.UserAgent = "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; EmbeddedWB 14.52 from: http://www.bsalsa.com/ EmbeddedWB 14.52; .NET4.0C; .NET4.0E; .NET CLR 2.0.50727; .NET CLR 3.0.04506.648; .NET CLR 3.5.21022; InfoPath.2)";
httpWebRequest.ContentType = "application/x-www-form-urlencoded";
//协议方式
httpWebRequest.Method = "POST";
//与internet建立持久连接
httpWebRequest.KeepAlive = true;
//post开始
//请求内容长度
httpWebRequest.ContentLength = byteArray.Length;
Stream dataStream = httpWebRequest.GetRequestStream();
// 请求数据放入请求流
dataStream.Write(byteArray, 0, byteArray.Length);
dataStream.Close();
//返回html
httpWebResponse = (HttpWebResponse)httpWebRequest.GetResponse();
if (httpWebResponse.StatusCode == HttpStatusCode.OK)
{
StreamReader reader = new StreamReader(httpWebResponse.GetResponseStream(), Encoding.GetEncoding("GBK"));
//读取响应流
string responseFromServer = reader.ReadToEnd();
reader.Close();
dataStream.Close();
httpWebResponse.Close();
if (responseFromServer.IndexOf("帖子发布成功") > 0)
{
TxtInfo.Text = "发贴成功";
}
else
{
TxtInfo.Text = responseFromServer;
}
}
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
}写自定义目录标题)
欢迎使用Markdown编辑器
你好! 这是你第一次使用 Markdown编辑器 所展示的欢迎页。如果你想学习如何使用Markdown编辑器, 可以仔细阅读这篇文章,了解一下Markdown的基本语法知识。
新的改变
我们对Markdown编辑器进行了一些功能拓展与语法支持,除了标准的Markdown编辑器功能,我们增加了如下几点新功能,帮助你用它写博客:
- 全新的界面设计 ,将会带来全新的写作体验;
- 在创作中心设置你喜爱的代码高亮样式,Markdown 将代码片显示选择的高亮样式 进行展示;
- 增加了 图片拖拽 功能,你可以将本地的图片直接拖拽到编辑区域直接展示;
- 全新的 KaTeX数学公式 语法;
- 增加了支持甘特图的mermaid语法1 功能;
- 增加了 多屏幕编辑 Markdown文章功能;
- 增加了 焦点写作模式、预览模式、简洁写作模式、左右区域同步滚轮设置 等功能,功能按钮位于编辑区域与预览区域中间;
- 增加了 检查列表 功能。
功能快捷键
撤销:Ctrl/Command + Z
重做:Ctrl/Command + Y
加粗:Ctrl/Command + B
斜体:Ctrl/Command + I
标题:Ctrl/Command + Shift + H
无序列表:Ctrl/Command + Shift + U
有序列表:Ctrl/Command + Shift + O
检查列表:Ctrl/Command + Shift + C
插入代码:Ctrl/Command + Shift + K
插入链接:Ctrl/Command + Shift + L
插入图片:Ctrl/Command + Shift + G
合理的创建标题,有助于目录的生成
直接输入1次#,并按下space后,将生成1级标题。
输入2次#,并按下space后,将生成2级标题。
以此类推,我们支持6级标题。有助于使用TOC
语法后生成一个完美的目录。
如何改变文本的样式
强调文本 强调文本
加粗文本 加粗文本
标记文本
删除文本
引用文本
H2O is是液体。
2