|
Good day!
I read several acticles about getting the "users online count" and "registered users count". However most of them were not full or lack performance. So i decided to make my own logic and i would like to share it with you. Can you please comment on it ? Is my logic wrong ?
Get registered users count:
DB logic:
- Store the count in a special table on the SQL server as a parameter. Increment the count when a new user is created. Decrement count when user is deleted ( or expired ). There is an alternative to SELECT COUNT(*) FROM Users...... but i discarded it. I don't think it's the best way to achieve my goal.
Get online users count:
DB logic:
- Store session information in a special table on the SQL server. Update the table whenever an activity is idicated ( the important here is the LastActiveDate and ExpirationDate ... which determine if the session is expired ).
- Logic for purging expired sessions and return the online users count after the purging.
ASP.NET
Web Server logic:
Web the application is started ( Application_Start Global.asax ) i start a System.TIMERS.TIMER with interval of 10 minutes. Every 10 minutes i get the registered users count, purge the expired sessions , get online users count and keep the stored data as static. On Application_End i dispose the timer.
However all my web forms are inherited by a base form in which "Page_Load" handler i idicate an activity and update the session information table on the sql server.
I'm not quite sure if my logic is right about all those steps. Please comment.
Best wishesh , Hristiyan
|
|
|
|
|
Hi,
1. Why do you store the user count separately? What is wrong with count(*)? You have to write much more code (possible point of bugs etc.) when you store the count in an extra table.
2. Why do you store the session information within a table? You could use a static dataobject (could be a simple int) within your ASP.NET application. Just increment/decrement the counter whenever a session ends (use Global.asax for this)
3. To update the visible count on your site just query the static dataobject to get the active users. To get all registered users use the sql-query. You could do something like "Store the value for one hour. After one hour ask query the registered users again" You don't need a timer for this, just do it in a master page whenever you get a postback. To update the site you could use a little JavaScript that will force the client to update in an interval.
Hope this helps you a bit.
Regards
Sebastian
|
|
|
|
|
Thank you for your answer !
My oppinion (I'm not saying it's correct.... it's just what i think) :
1. Assume i have 100 000 users. SELECT COUNT(*) "count every time all the users when that statement is executed". Thats some really big unnecessary weight over the SQL server. I don't think thats the right approach.
2. I think that logic is incorrect. You don't increment and decrement the the online users when the Session_Start and Session_End. Assume that the user closes the browser. The logic fails there - it will actually count that user as online.
3. I think that logic is incorrect. You cannot query the database with that unnecessary logic weight every time there is a postback. That will make a segnificant performance loss.
I store the session info in the database, because it's needed for other purposes too. However i update it every time a user makes a postback and purge the expired data every 10 minutes.
Please give advices.
Best wishes , Hristiyan !
|
|
|
|
|
1.+3. Well that's why I said you could store it in a variable that will be update every hour or so...
2. The problem is that you can't get the event if the user closes the browser. What you will get is a session end, when the timeout expires... so the mechanism implemented with the session object (timeout etc.) is the same as you have written by yourself (as you explained in your first message).
Every I/O action takes time. If you have 10.000 users online you will have at approx. 1.000 sql inserts/updates every minute when you update the session data within your sql server. Using a select count(*) every hour seems a blink of an eye to me then.
Regards
Sebastian
|
|
|
|
|
However , since i've already implemented my logic ( now i'm testing it ), i'm going to ask you in general: Do you strong disagree with my logic ?
Do you see a reasonable point to delete my current implementation and "make it the easy way" ?
Regards , Hristiyan
|
|
|
|
|
If you already implemented it and it is working I wouldn't throw away the logic. But if you encouter any problems at a later point I would think about refactoring.
Regards
Sebastian
|
|
|
|
|
Hello,
I have an ecommerce website where I have a page named "buynow.aspx". In this page's code behind file, (buynow.aspx.cs) I have referenced many classes which are available in App_Code folder. Also this page calls many classes whose dlls are in Bin folder of the Web application.
Now, I want to accept credit card payments in buynow.aspx page and so I will need to place this page in the httpsdocs folder of my web server. Now, my question is, will I need to create Bin folder, App_Code folder, etc all in the httdocs folder ? Or, is there any smart way so that I can place some information in Web.Config file so that, only buynow.aspx page is treated as SSL page but I dont need to create a duplicate Web application in the httpsdocs folder of my hosting ?
NB:I searched in google about this specific tutorial but did not find any (may be I dont know the right keyword). If you have any article link, please let me know too.
Regards
|
|
|
|
|
i have a userControl and am using it in a aspx page, now i have expose the Following Method that reside in the usercontrol like this
public void load_Again()
{
string clientscript = "";
clientscript = "var txtbxActvClientID = '" + txtbxActvs.ClientID.ToString() + "'; ";
ClientScriptManager cs = Page.ClientScript;
cs.RegisterClientScriptBlock(this.GetType(), "txtbxlookupid", clientscript, true);
HighlightSelectedActvs();
}
and am calling it on my aspx page like this
ActivityCtrl1.load_Again();
i have Copied the code you see in the method load_Again() from the page load event of the Control. I want refresh or load the page again after i click a button in my aspx page.
Thank you
Vuyiswa Maseko,
Few companies that installed computers to reduce the employment of clerks have realized their expectations.... They now need more and more expensive clerks even though they call them "Developers" or "Programmers."
C#/VB.NET/ASP.NET/SQL7/2000/2005/2008
http://www.vuyiswamaseko.tiyaneProperties.co.za
vuyiswa@its.co.za
http://www.itsabacus.co.za/itsabacus/
|
|
|
|
|
use button as asp:button and it will do a postback call where you can do whatever you want.
Prince
www.imaginethinkact.com
|
|
|
|
|
I really don't understand what you just wrote , can you please explain clearer ?
Vuyiswa Maseko,
Few companies that installed computers to reduce the employment of clerks have realized their expectations.... They now need more and more expensive clerks even though they call them "Developers" or "Programmers."
C#/VB.NET/ASP.NET/SQL7/2000/2005/2008
http://www.vuyiswamaseko.tiyaneProperties.co.za
vuyiswa@its.co.za
http://www.itsabacus.co.za/itsabacus/
|
|
|
|
|
ActivityCtrl1.load_Again();
Is this written on Page_Load of your aspx page?
|
|
|
|
|
Yes and declared Public in the User Control
Vuyiswa Maseko,
Few companies that installed computers to reduce the employment of clerks have realized their expectations.... They now need more and more expensive clerks even though they call them "Developers" or "Programmers."
C#/VB.NET/ASP.NET/SQL7/2000/2005/2008
http://www.vuyiswamaseko.tiyaneProperties.co.za
vuyiswa@its.co.za
http://www.itsabacus.co.za/itsabacus/
|
|
|
|
|
Can you put this code (for LoadAgain()) inside the page load event of user control?
If it is a dynamic user control, it needs to be regenerated on post back of page.
Thanks & Regards,
Nyoti
|
|
|
|
|
After the button has been clicked i have Forced a Postback by doing this
response.redirect("Subjectscruct.aspx",false");
and it worked, is this an efficient way ?
Thank you
Vuyiswa Maseko,
Few companies that installed computers to reduce the employment of clerks have realized their expectations.... They now need more and more expensive clerks even though they call them "Developers" or "Programmers."
C#/VB.NET/ASP.NET/SQL7/2000/2005/2008
http://www.vuyiswamaseko.tiyaneProperties.co.za
vuyiswa@its.co.za
http://www.itsabacus.co.za/itsabacus/
|
|
|
|
|
If the button is in the page, I am not sure why it was needed to execute Postback forcefully?
Did you try debugging on the page load on the click of button to check if the control comes there?
Thanks,
Nyoti
|
|
|
|
|
hi,
I am trying to use ajax tab panels to gather information from a user. I have controls in the first tab which I would like to vaildate before moving to the second tab. Is there a way I can force the user to stay in the 1st tab if they havent satisied the validation? how to stop the user from moving to the next tab?
regards,
Bill
|
|
|
|
|
Hi, I think you must set the properties of your tab panel to autopostback=true
and then in your tabpanel
If tabs.ActiveTabIndex = 1 Then
textbox1.Text = "sayre"
End If
Hope this one can help.
Thanks
|
|
|
|
|
Hi i am trying to import contacts from AOL and hotmail
i have done it in Gmail and yahoo but not able to do for Hotmail and AOL
will anybody send me some help.
Thanks & Regards,
Prashant B. Lavate
Software Engineer
Mobile : +919423872257
Pune(India)
|
|
|
|
|
What kind of problem are you facing when you try it for hotmail or AOL? Do you get some kind of error?
|
|
|
|
|
in hotmil it is not giving location so null is coming
Thanks & Regards,
Prashant B. Lavate
Software Engineer
Mobile : +919423872257
Pune(India)
|
|
|
|
|
Okay??? so could you post a bit of the code and point to the line where the error occurs?
|
|
|
|
|
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
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)
|
|
|
|
|
And the line where the error occurs?
|
|
|
|
|
string strNextUrlTemp = webResMailLiveComASPX.Headers[Utility.Location].ToString();
it is giving null
Thanks & Regards,
Prashant B. Lavate
Software Engineer
Mobile : +919423872257
Pune(India)
|
|
|
|
|
Okay, and what is Utility.Location (the string)? Is it important, or can you just ignore it for AOL and Hotmail? Maybe these both don't provide the value?
|
|
|
|