日期:2014-05-20  浏览次数:20621 次

请问一个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就可以了呀!!!