首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > J2SE开发 >

请教一个java带sessionid访问asp.NET的有关问题

2012-01-16 
请问一个java带sessionid访问asp.NET的问题?C# codeHttpWebRequest myReq (HttpWebRequest)WebRequest.C

请问一个java带sessionid访问asp.NET的问题?

C# code
           HttpWebRequest myReq = (HttpWebRequest)WebRequest.Create(strUrl);            myReq.Method = "post";            UTF8Encoding encoding = new UTF8Encoding();            CookieContainer cookies = new CookieContainer();            myReq.CookieContainer = cookies;            Cookie appCookie = new Cookie("ASP.NET_SessionId", sessionid);            myReq.CookieContainer.Add(new Uri(strUrl), appCookie);            myReq.ContentLength = byte1.Length;            myReq.ReadWriteTimeout = 1000;            Stream newStream = myReq.GetRequestStream();            newStream.Write(byte1, 0, byte1.Length);            newStream.Close();

我使用c#代码可以访问ASP.NET的webserver,但是我使用java的代码访问ASP.NET的webserver就不可以通过?
  URL url = new URL("http://192.168.1.18/web/Default.aspx");
mUrlConn = (HttpURLConnection)url.openConnection();
mUrlConn.setRequestMethod("POST");
mUrlConn.setRequestProperty("Connection", "Keep-Alive");
mUrlConn.setRequestProperty("Content-Type" , "application/x-www-form-urlencoded");
mUrlConn.setDoOutput(true);
mUrlConn.setDoInput(true);
mUrlConn.setConnectTimeout(5000);
if(Constants.SESSIONID != null){
mUrlConn.setRequestProperty("Cookie", Constants.SESSIONID);
}
怎么我使用java带sessionid访问,ASP.net的webserver会不认为存在此sessionid?

[解决办法]
在前面加上ASP_NET.SESSIONID就可以了呀!!!

热点排行