Click here to Skip to main content
16,005,048 members
Home / Discussions / ASP.NET
   

ASP.NET

 
GeneralRe: How to ReFresh a user Control Pin
Nyoti Rukadikar23-Apr-09 2:05
Nyoti Rukadikar23-Apr-09 2:05 
Questionajax tab panel validation Pin
billcodes22-Apr-09 21:34
billcodes22-Apr-09 21:34 
AnswerRe: ajax tab panel validation Pin
SayreCC22-Apr-09 22:19
SayreCC22-Apr-09 22:19 
QuestionImporting contacts from hotmail and aol Pin
Prashant B. Lavate22-Apr-09 20:56
Prashant B. Lavate22-Apr-09 20:56 
AnswerRe: Importing contacts from hotmail and aol Pin
SeMartens22-Apr-09 21:15
SeMartens22-Apr-09 21:15 
GeneralRe: Importing contacts from hotmail and aol Pin
Prashant B. Lavate22-Apr-09 21:57
Prashant B. Lavate22-Apr-09 21:57 
GeneralRe: Importing contacts from hotmail and aol Pin
SeMartens22-Apr-09 22:19
SeMartens22-Apr-09 22:19 
GeneralRe: Importing contacts from hotmail and aol Pin
Prashant B. Lavate22-Apr-09 22:36
Prashant B. Lavate22-Apr-09 22:36 
public void GetContacts(string strUserName, string strPassword, out bool boolIsOK, out DataTable dtContatct, out string strError)
{
//default values
dtContatct = new DataTable();
boolIsOK = true;
strError = string.Empty;
// ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(MyCertValidation);

//1=================================================================================================================
//http://mail.live.com the AllowAutoRedirect will call the next url subsequently
//http://login.live.com/login.srf?wa=wsignin1.0&rpsnv=10&ct=1193552878&rver=4.5.2130.0&wp=MBI&wreply=http:%2F%2Fmail.live.com%2Fdefault.aspx&id=64855
String strRequestUrl = "http://mail.live.com";
HttpWebRequest webReqFirstPage = (HttpWebRequest)WebRequest.Create(strRequestUrl);
webReqFirstPage.Method = Utility.Get;
webReqFirstPage.KeepAlive = true;
webReqFirstPage.AllowAutoRedirect = true;
webReqFirstPage.CookieContainer = new CookieContainer();
webReqFirstPage.UseDefaultCredentials = true;
webReqFirstPage.UserAgent = Utility.UserAgent;

HttpWebResponse webResFirstPage = (HttpWebResponse)webReqFirstPage.GetResponse();
CookieCollection ccWebReqFirstPage = new CookieCollection();
if (webResFirstPage.Headers[Utility.SetCookie] != null)
{
ccWebReqFirstPage = Utility.GetAllCookiesFromHeader(webResFirstPage.Headers[Utility.SetCookie], webResFirstPage.ResponseUri.Host);
}
StreamReader sr1 = new StreamReader(webResFirstPage.GetResponseStream());
String strFirstPage = sr1.ReadToEnd();
sr1.Close();
webResFirstPage.Close();
webReqFirstPage.Abort();

//this is the url for 3rd request
string strLoginUrlTemp = Utility.GetRegExParsedValue("srf_uPost='(?<retval>.*?)'", strFirstPage); //For 3rd Request
//keeping values from the FORM for 3rd request
string strPPSXValue = Utility.GetRegExParsedValue("srf_sRBlob='(?<retval>.*?)'", strFirstPage);
string strPPFTValue = Utility.GetRegExParsedValue("<input.*?name>.*?)\"/>", strFirstPage);
//this page call the 2nd request through javascrpt..for this collecting the url
string strBaseUrl = Utility.GetRegExParsedValue("<base\\s*href>.*?)\"\\s*/>", strFirstPage); ;
string strPageUrl = Utility.GetRegExParsedValue("<script.*?src>.*?)\">", strFirstPage); ;
string strFullUrl = strBaseUrl + strPageUrl;//For 2nd request
//2=================================================================================================================
//http://login.live.com/pp500/WLLogin_JS.srf?x=5.0.7495.0&lc=1033
string strRequestUrlJSCall = strFullUrl;
HttpWebRequest webReqJSCall = (HttpWebRequest)WebRequest.Create(strRequestUrlJSCall);
webReqJSCall.Method = Utility.Get;
webReqJSCall.KeepAlive = true;
webReqJSCall.AllowAutoRedirect = false;
webReqJSCall.UseDefaultCredentials = true;
webReqJSCall.UserAgent = Utility.UserAgent;
webReqJSCall.Referer = webResFirstPage.ResponseUri.ToString();
webReqJSCall.CookieContainer = new CookieContainer();
webReqJSCall.CookieContainer.Add(ccWebReqFirstPage);

HttpWebResponse webResJSCall = (HttpWebResponse)webReqJSCall.GetResponse();
StreamReader sr1JSCall = new StreamReader(webResJSCall.GetResponseStream());
string strJSCall = sr1JSCall.ReadToEnd();
sr1JSCall.Close();
webResJSCall.Close();
webReqJSCall.Abort();
//this cookie created through javascript
Cookie cookCkTst = new Cookie("CkTst", Utility.GetJavaScriptTime(), "/", ".live.com");
ccWebReqFirstPage.Add(cookCkTst);
//keeping values from the FORM for 3rd request
string strPwdPad = Utility.GetRegExParsedValue("sPad=\"(?<retval>.*?)\"", strJSCall); // i have time man Smile | :)
string stridsbho = Utility.GetRegExParsedValue("\"idsbho\",\".*?\",\"(?<retval>.*?)\"", strJSCall);
//3=================================================================================================================
//https://login.live.com/ppsecure/post.srf?wa=wsignin1.0&rpsnv=10&ct=1193552878&rver=4.5.2130.0&wp=MBI&wreply=http:%2F%2Fmail.live.com%2Fdefault.aspx&id=64855&bk=1193552881
string strLoginUrl = strLoginUrlTemp;
string strLoginBody = "idsbho=" + stridsbho + "&PwdPad=" + strPwdPad + "&LoginOptions=2&CS=&FedState=&PPSX=" + strPPSXValue + "&type=11&login=" + strUserName + "&passwd=" + strPassword + "&remMe=1&NewUser=1&PPFT=" + strPPFTValue + "&i1=0&i2=2";
HttpWebRequest webReqLogin = (HttpWebRequest)WebRequest.Create(strLoginUrl);
webReqLogin.Method = Utility.Post;
webReqLogin.UserAgent = Utility.UserAgent;
webReqLogin.KeepAlive = true;
webReqLogin.ContentType = Utility.ContentTypeUrlEncoded;
webReqLogin.UseDefaultCredentials = true;
webReqLogin.Referer = webResFirstPage.ResponseUri.ToString(); ;
webReqLogin.CookieContainer = new CookieContainer();
webReqLogin.CookieContainer.Add(ccWebReqFirstPage);
webReqLogin.ContentLength = strLoginBody.Length;
StreamWriter sw = new StreamWriter(webReqLogin.GetRequestStream());
sw.Write(strLoginBody);
sw.Close();

HttpWebResponse webResLogin = (HttpWebResponse)webReqLogin.GetResponse();
CookieCollection ccWebResLogin = new CookieCollection();
if (webResLogin.Headers[Utility.SetCookie] != null)
{
ccWebResLogin = Utility.GetAllCookiesFromHeader(webResLogin.Headers[Utility.SetCookie], webResLogin.ResponseUri.Host);
}
string strNewResponseUrl = webResLogin.ResponseUri.ToString();
StreamReader sr = new StreamReader(webResLogin.GetResponseStream());
string strMainPage = sr.ReadToEnd();
sr.Close();
webResLogin.Close();
webReqLogin.Abort();
//Get the next url for 4 th request
string strMailLiveComUrlTemp = Utility.GetRegExParsedValue("replace\\(\"(?<retval>.*?)\"\\)", strMainPage);
if (strMailLiveComUrlTemp == string.Empty)
{
boolIsOK = false;
strError = Utility.UseridPassWrong;
return;
}
//4=================================================================================================================
//http://mail.live.com/default.aspx?wa=wsignin1.0..only for UI cookie
string strMailLiveComUrl = strMailLiveComUrlTemp;
HttpWebRequest webReqMailLiveComASPX = (HttpWebRequest)WebRequest.Create(strMailLiveComUrl);
webReqMailLiveComASPX.Method = Utility.Get;
webReqMailLiveComASPX.Accept = Utility.AcceptAll;
webReqMailLiveComASPX.UserAgent = Utility.UserAgent;
webReqMailLiveComASPX.KeepAlive = true;
webReqMailLiveComASPX.AllowAutoRedirect = false;
webReqMailLiveComASPX.UseDefaultCredentials = true;
webReqMailLiveComASPX.CookieContainer = new CookieContainer();
webReqMailLiveComASPX.CookieContainer.Add(ccWebResLogin);
HttpWebResponse webResMailLiveComASPX = (HttpWebResponse)webReqMailLiveComASPX.GetResponse();
CookieCollection ccWebResMailLiveComASPX = new CookieCollection();
if (webResMailLiveComASPX.Headers[Utility.SetCookie] != null)
{
ccWebResMailLiveComASPX = Utility.GetAllCookiesFromHeader(webResMailLiveComASPX.Headers[Utility.SetCookie], webResMailLiveComASPX.ResponseUri.Host);
}
StreamReader srMailLiveCom = new StreamReader(webResMailLiveComASPX.GetResponseStream());
string strMailLiveComPage = srMailLiveCom.ReadToEnd();
srMailLiveCom.Close();
webResMailLiveComASPX.Close();
webReqMailLiveComASPX.Abort();
//start---keeping values for next request..first half looks:"http://by112w.bay112.mail.live.com/mail/
string strNextUrlTemp = webResMailLiveComASPX.Headers[Utility.Location].ToString();
//string strNextUrlTemp = Utility.GetRegExParsedValue("replace\\(\"(?<retval>.*?)\"\\)", strMainPage);
string strFirstHalfUrlTemp = Utility.GetRegExParsedValue(@"(?<retval>.*?mail/)", strNextUrlTemp);
if (strNextUrlTemp == string.Empty)
{
boolIsOK = false;
strError = Utility.ApplicationError;
return;
}
//5=================================================================================================================
//http://by112w.bay112.mail.live.com/mail/TodayLight.aspx?wa=wsignin1.0&n=1317674709&gs=true
string strByBayUrl = strNextUrlTemp;
HttpWebRequest webReqByBayASPX = (HttpWebRequest)WebRequest.Create(strByBayUrl);
webReqByBayASPX.Method = Utility.Get;
webReqByBayASPX.UserAgent = Utility.UserAgent;
webReqByBayASPX.KeepAlive = true;
webReqByBayASPX.AllowAutoRedirect = false;
webReqByBayASPX.UseDefaultCredentials = true;
webReqByBayASPX.CookieContainer = new CookieContainer();
webReqByBayASPX.CookieContainer.Add(ccWebResLogin);
webReqByBayASPX.CookieContainer.Add(ccWebResMailLiveComASPX);
HttpWebResponse webResByBayASPX = (HttpWebResponse)webReqByBayASPX.GetResponse();
CookieCollection ccWebResByBayASPX = new CookieCollection();
if (webResByBayASPX.Headers[Utility.SetCookie] != null)
{
ccWebResByBayASPX = Utility.GetAllCookiesFromHeader(webResByBayASPX.Headers[Utility.SetCookie], webResByBayASPX.ResponseUri.Host);
}
StreamReader srByBay = new StreamReader(webResByBayASPX.GetResponseStream());
string strByBayPage = srByBay.ReadToEnd();
srByBay.Close();
webResByBayASPX.Close();
webReqByBayASPX.Abort();
//keep options page url for next request... if it is CLASSIC version
string strOptionsPageUrlTemp = Utility.GetRegExParsedValue(@"<a.*?href>.*?)"".*?id=""Options"".*?>", strByBayPage);
if (strOptionsPageUrlTemp == string.Empty) //If it is FULL version
{
strOptionsPageUrlTemp = "options.aspx?subsection=1&n=" + Utility.GetJavaScriptTime();
}
string strOptionsPageUrl = strFirstHalfUrlTemp + strOptionsPageUrlTemp;
if (strOptionsPageUrlTemp == string.Empty)
{
boolIsOK = false;
strError = Utility.ApplicationError;
return;
}
//6=================================================================================================================
//http://by112w.bay112.mail.live.com/mail/options.aspx?subsection=1&n=506906558
string strOptionsUrl = strOptionsPageUrl;
HttpWebRequest webReqOptionsASPX = (HttpWebRequest)WebRequest.Create(strOptionsUrl);
webReqOptionsASPX.Method = Utility.Get;
webReqOptionsASPX.UserAgent = Utility.UserAgent;
webReqOptionsASPX.KeepAlive = true;
webReqOptionsASPX.AllowAutoRedirect = false;
webReqOptionsASPX.Referer = strByBayUrl;
webReqOptionsASPX.UseDefaultCredentials = true;
webReqOptionsASPX.CookieContainer = new CookieContainer();
webReqOptionsASPX.CookieContainer.Add(ccWebResLogin);
webReqOptionsASPX.CookieContainer.Add(ccWebResMailLiveComASPX);
webReqOptionsASPX.CookieContainer.Add(ccWebResByBayASPX);

HttpWebResponse webResOptionsASPX = (HttpWebResponse)webReqOptionsASPX.GetResponse();
CookieCollection ccwebResOptionsASPX = new CookieCollection();
if (webResOptionsASPX.Headers[Utility.SetCookie] != null)
{
ccwebResOptionsASPX = Utility.GetAllCookiesFromHeader(webResOptionsASPX.Headers[Utility.SetCookie], webResOptionsASPX.ResponseUri.Host);
}
StreamReader srOptions = new StreamReader(webResOptionsASPX.GetResponseStream());
string strOptionsPage = srOptions.ReadToEnd();
srOptions.Close();
webResOptionsASPX.Close();
webReqOptionsASPX.Abort();

//keeping export page url for next request
string strExportPageUrlTemp = Utility.GetRegExParsedValue(@"<a\s*href>.*?)"".*?>\s*Export.*?contacts", strOptionsPage);
string strExportPageUrl = strFirstHalfUrlTemp + strExportPageUrlTemp;
if (strExportPageUrlTemp == string.Empty)
{
boolIsOK = false;
strError = Utility.ApplicationError;
return;
}
//7=================================================================================================================
//http://by112w.bay112.mail.live.com/mail/options.aspx?subsection=26&n=1234655194
string strExpContactsUrl = strExportPageUrl;
HttpWebRequest webReqExpContactsASPX = (HttpWebRequest)WebRequest.Create(strExpContactsUrl);
webReqExpContactsASPX.Method = Utility.Get;
webReqExpContactsASPX.UserAgent = Utility.UserAgent;
webReqExpContactsASPX.KeepAlive = true;
webReqExpContactsASPX.AllowAutoRedirect = false;
webReqExpContactsASPX.ContentType = Utility.ContentTypeTextHtml;
webReqExpContactsASPX.UseDefaultCredentials = true;
webReqExpContactsASPX.CookieContainer = new CookieContainer();
webReqExpContactsASPX.CookieContainer.Add(ccWebResLogin);
webReqExpContactsASPX.CookieContainer.Add(ccWebResMailLiveComASPX);
webReqExpContactsASPX.CookieContainer.Add(ccWebResByBayASPX);

HttpWebResponse webResExpContactsASPX = (HttpWebResponse)webReqExpContactsASPX.GetResponse();
CookieCollection ccWebResExpContactsASPX = new CookieCollection();
if (webResExpContactsASPX.Headers[Utility.SetCookie] != null)
{
ccWebResExpContactsASPX = Utility.GetAllCookiesFromHeader(webResExpContactsASPX.Headers[Utility.SetCookie], webResExpContactsASPX.ResponseUri.Host);
}
StreamReader srExpContacts = new StreamReader(webResExpContactsASPX.GetResponseStream());
string strExpContactsPage = srExpContacts.ReadToEnd();
srExpContacts.Close();
webResExpContactsASPX.Close();
webReqExpContactsASPX.Abort();

//keeping export page url for next request
string strContactsCSVTemp = Utility.GetRegExParsedValue(@"<form.*?name>.*?)"".*?>", strExpContactsPage);
string strContactsCSV = strFirstHalfUrlTemp + strContactsCSVTemp;
//start collect BODY values for next request
//getting value for postback: __VIEWSTATE
string strVIEWSTATE = Utility.GetRegExParsedValue(@"<input.*?name>.*?)"".*?/>", strExpContactsPage);
//getting value for postback: __EVENTVALIDATION
string strEVENTVALIDATION = Utility.GetRegExParsedValue(@"<input.*?name>.*?)"".*?/>", strExpContactsPage);
//getting value for postback: mt //Utility.GetRegExParsedValue(@"<input.*?name>.*?)"".*?/>", strExpContactsPage);
string strmt = ccWebResByBayASPX["mt"].Value;
//getting value for postback: ctl01$ExportButton
string strExportButton = Utility.GetRegExParsedValue("<input.*?name>.*?)\".*?value=\"Export contacts\".*?/>", strExpContactsPage) + "=" + "Export contacts";
if (strContactsCSVTemp == "" || strVIEWSTATE == "" || strEVENTVALIDATION == "" || strmt == "" || strExportButton == "")
{
boolIsOK = false;
strError = Utility.ApplicationError;
return;
}
strVIEWSTATE = "__VIEWSTATE=" + strVIEWSTATE;
strEVENTVALIDATION = "__EVENTVALIDATION=" + strEVENTVALIDATION;
strmt = "mt=" + strmt;

//8=================================================================================================================
//http://by112w.bay112.mail.live.com/mail/options.aspx?subsection=26&n=938064379
string strCSVUrl = strContactsCSV;
HttpWebRequest webReqCSVASPX = (HttpWebRequest)WebRequest.Create(strCSVUrl);
string strCSVBody = strVIEWSTATE + "&" + strmt + "&" + strExportButton + "&" + strEVENTVALIDATION;
webReqCSVASPX.Method = Utility.Post;
webReqCSVASPX.UserAgent = Utility.UserAgent;
webReqCSVASPX.KeepAlive = true;
webReqCSVASPX.Referer = strExpContactsUrl;
webReqCSVASPX.AllowAutoRedirect = true;
webReqCSVASPX.ContentType = Utility.ContentTypeUrlEncoded;
webReqCSVASPX.UseDefaultCredentials = true;
webReqCSVASPX.CookieContainer = new CookieContainer();
webReqCSVASPX.CookieContainer.Add(ccWebResLogin);
webReqCSVASPX.CookieContainer.Add(ccWebResMailLiveComASPX);
webReqCSVASPX.CookieContainer.Add(ccWebResByBayASPX);

StreamWriter sw4 = new StreamWriter(webReqCSVASPX.GetRequestStream());
sw4.Write(strCSVBody); sw4.Close();

HttpWebResponse webResCSVASPX = (HttpWebResponse)webReqCSVASPX.GetResponse();
CookieCollection ccWebResCSVASPX = new CookieCollection();
if (webResCSVASPX.Headers[Utility.SetCookie] != null)
{
ccWebResCSVASPX = Utility.GetAllCookiesFromHeader(webResCSVASPX.Headers[Utility.SetCookie], webResCSVASPX.ResponseUri.Host);
}
webResCSVASPX.Cookies = webReqCSVASPX.CookieContainer.GetCookies(webReqCSVASPX.RequestUri);
StreamReader srCSV = new StreamReader(webResCSVASPX.GetResponseStream());
string strCSVPage = srCSV.ReadToEnd();
srCSV.Close();
webResCSVASPX.Close();
webReqCSVASPX.Abort();
if (strCSVPage == string.Empty)
{
boolIsOK = false;
strError = Utility.ApplicationError;
return;
}
//=================================================================================================================
boolIsOK = true;
dtContatct = Utility.ConvertCSVIntoDataTable(strCSVPage);
strError = string.Empty;
}

Thanks & Regards,
Prashant B. Lavate
Software Engineer
Mobile : +919423872257
Pune(India)

GeneralRe: Importing contacts from hotmail and aol Pin
SeMartens22-Apr-09 22:39
SeMartens22-Apr-09 22:39 
GeneralRe: Importing contacts from hotmail and aol Pin
Prashant B. Lavate22-Apr-09 23:22
Prashant B. Lavate22-Apr-09 23:22 
GeneralRe: Importing contacts from hotmail and aol Pin
SeMartens22-Apr-09 23:37
SeMartens22-Apr-09 23:37 
GeneralRe: Importing contacts from hotmail and aol Pin
Prashant B. Lavate22-Apr-09 23:55
Prashant B. Lavate22-Apr-09 23:55 
GeneralRe: Importing contacts from hotmail and aol [modified] Pin
SeMartens22-Apr-09 23:59
SeMartens22-Apr-09 23:59 
GeneralRe: Importing contacts from hotmail and aol Pin
mariahayek23-Apr-09 0:55
mariahayek23-Apr-09 0:55 
GeneralRe: Importing contacts from hotmail and aol Pin
SeMartens23-Apr-09 1:36
SeMartens23-Apr-09 1:36 
QuestionIframe Related Help! Pin
mr_muskurahat22-Apr-09 20:41
mr_muskurahat22-Apr-09 20:41 
AnswerRe: Iframe Related Help! Pin
SayreCC22-Apr-09 20:47
SayreCC22-Apr-09 20:47 
AnswerRe: Iframe Related Help! Pin
Nyoti Rukadikar23-Apr-09 0:30
Nyoti Rukadikar23-Apr-09 0:30 
QuestionA first chance exception of type 'System.Threading.ThreadAbortException' occurred in mscorlib.dll An exception of type 'System.Threading.ThreadAbortException' occurred in mscorlib.dll but was not handled in user code ? Pin
Subin Alex22-Apr-09 20:19
Subin Alex22-Apr-09 20:19 
AnswerRe: A first chance exception of type 'System.Threading.ThreadAbortException' occurred in mscorlib.dll An exception of type 'System.Threading.ThreadAbortException' occurred in mscorlib.dll but was not handled in user code ? Pin
N a v a n e e t h22-Apr-09 20:30
N a v a n e e t h22-Apr-09 20:30 
AnswerRe: A first chance exception of type 'System.Threading.ThreadAbortException'..... Pin
Abhijit Jana22-Apr-09 20:38
professionalAbhijit Jana22-Apr-09 20:38 
AnswerRe: A first chance exception of type 'System.Threading.ThreadAbortException' occurred in mscorlib.dll An exception of type 'System.Threading.ThreadAbortException' occurred in mscorlib.dll but was not handled in user code ? Pin
smurariu22-Apr-09 23:46
smurariu22-Apr-09 23:46 
QuestionHref in Grid Pin
member2722-Apr-09 20:12
member2722-Apr-09 20:12 
AnswerRe: Href in Grid Pin
SayreCC22-Apr-09 20:20
SayreCC22-Apr-09 20:20 
GeneralRe: Href in Grid Pin
member2723-Apr-09 2:05
member2723-Apr-09 2:05 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.