猿问

c# cs程序与bs程序交互

c# cs程序与bs程序交互


UYOU
浏览 825回答 2
2回答

HUWWW

1234567891011121314///&nbsp;<summary>&nbsp;&nbsp;///&nbsp;判断是否是web程序&nbsp;&nbsp;///&nbsp;</summary>&nbsp;&nbsp;///&nbsp;<returns>true:是,false:winform</returns>&nbsp;&nbsp;public&nbsp;bool&nbsp;IsWebApp()&nbsp;&nbsp;{&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;bool&nbsp;flag&nbsp;=&nbsp;false;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;(HttpContext.Current&nbsp;!=&nbsp;null)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;flag&nbsp;=&nbsp;true;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//否则是winform程序&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;flag;&nbsp;&nbsp;}&nbsp;

开心每一天1111

HttpWebRequest HttpWReq = (HttpWebRequest)WebRequest.Create("XXXXX");HttpWReq.KeepAlive = false;HttpWReq.Method = "Post";HttpWReq.CookieContainer = new&nbsp;CookieContainer();HttpWReq.CookieContainer.Add(new Cookie("name", "value"));HttpWebResponse HttpWResp = (HttpWebResponse)HttpWReq.GetResponse();HttpWResp.Close();
随时随地看视频慕课网APP
我要回答