|
dear sir,
i am trying to access reddit.com through c# code.
i am using this code:
public void Prepare_Url()
{
try
{
string response = Send_Request("http://www.reddit.com", null);
string postdata ="op=login-main&user=yogeshyahoo&passwd=yogesh&id=%23login_login-main";
response = Send_Request("http://www.reddit.com", postdata);
txtResponse.Text = response;
}
catch (Exception ex)
{
Console.WriteLine("Exception" + ex.Message);
}
}
public string Send_Request(string link, string post_data)
{
//try
//{
string url = string.Format(link);
HttpWebRequest request = (HttpWebRequest )WebRequest.Create(url);
request.UserAgent = "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.20) Gecko/20081217 Firefox/2.0.0.20";
request.Method = "GET";
request.Accept = "text/xml,application/xml,application/xhtml+xml,text/html,application/json, text/javascript;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5";
request.KeepAlive = true;
request.ContentType = @"application/x-www-form-urlencoded";
request.Referer = string.Format("http://www.reddit.com");
request.CookieContainer = new CookieContainer();
request.CookieContainer.Add(cookies);
request.Timeout = 600000;
request.AllowAutoRedirect = false;
//equest.Credentials = new NetworkCredential("yogeshyahoo","yogesh");
request.PreAuthenticate = true;
if (post_data != null)
{//post the data to the desired link
string postData = post_data;
request.Method = "POST";
byte[] postBuffer = System.Text.Encoding.GetEncoding(1252).GetBytes(postData);
Stream postDataStream = request.GetRequestStream();
postDataStream.Write(postBuffer, 0, postBuffer.Length);
postDataStream.Close();
}
string s;
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
cookies.Add(response.Cookies);
Encoding enc = System.Text.Encoding.UTF8;
StreamReader sr = new StreamReader(response.GetResponseStream(), enc, true);
s=sr.ReadToEnd();
return s;
// }
//catch (Exception ex)
//{
// MessageBox.Show("Error: " + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Information);
// Console.WriteLine(ex.Message);
// return string.Empty;
//}
}
this code is working for url:www.reddit.com correctly.
ok its ok
but for login i am not getting correct url (Live http header software plugin in firfox)
i am getting www.reddit.com/api/login/<<username>>
but this is not working
im geting error. 404 page not found.
could you please give me idea.
yogesh
|
|
|
|
|
|
This is scary long.. any chance you could make it a bit smaller?
|
|
|
|
|
|
please does anyone have an idea if i can use just any bluetooth with a project that involves using a pair of bluetooth for data acquisition . i hope i dont have to write another code for the bluetooth before i can use them.
|
|
|
|
|
Started to read WCF recentenly. I have couple of questions
Suppose I have two classes Class1 and Class2
For Class1 -- IClass1 is the interface
For Class2 -- IClass2 is the interface
How do i expose these interface using one service
<services>
<service name="MyService">
<endpoint>
address = "net.tcp://localhost:8000/Class1/"
binding = "netTcpBinding"
contract = "IClass1"
<endpoint>
address = "net.tcp://localhost:8001/Class2/"
binding = "netTcpBinding"
contract = "IClass2"
My questions
1) in the adress where i used Class1 and Class2
can i use anything for class1 and class2 or should it be Class names or it
should it be servicename ?
2) Every time i expose an interface should i expose at different ports or can i expose at the same port if i expose them at the same port should the binding be different or for the same service can i expose two interfaces with the same port and with the same binding
Iam new to WCF so please let me know if iam not making any sense
|
|
|
|
|
1) You don't have to use the class name.
2) You must use different ports, as each interface (service) will have its endpoint.
|
|
|
|
|
If i have one service but two endpoints and each end point pointing to a different interface. Then will they have to use a different port every time. That means suppose if i expose my methods using ten different interface then each interface should expose thorugh a different port.
In my company situation i have 20 business layer dll's and each dll has its own interface. If i need to convert this into wcf application and if i want to use only one wcf service and 20 end points in this situation then ecah end point should use a different port ??
|
|
|
|
|
If you use different URLs for the endpoint, then it's OK, for example:
http://localhost:9000/ServiceA/
http://localhost:9000/ServiceB/
|
|
|
|
|
Hello,
I have created a datagridview using C# windows application and I am having formatting issues with the data once the datagridview has been populated. The way I have this set up is before I bind the data to the binding source I add a new row which contains combo boxes. These Como boxes are used to populate the new headers. Once the headers have been modified the data needs to be formatted to data types the system can handle. For example, the datagridview populates dates as mm/dd/yyyy 00.00.00 AM but I need to reformat this to mm/dd/yyyy. I have created a method that loops through each cell in the first row and captures the new header (which works) but when the code that is suppose to reformat the column runs, it doesn't work. the code I have to reformat the columns based on the logic used is dataGridView1.Columns[c].DefaultCellStyle.Format = "d";. However, this doesn't work. Can someone please help me? It is much appreciated. Here is what I have and if it is not enough then let me know and I can post more code.
private void button10_Click(object sender, EventArgs e)
{
if (radioButton1.Checked == true)
{
string[] newHeaders = new string[dataGridView1.ColumnCount];
int n = dataGridView1.ColumnCount;
int c = 0;
for (c = 0; c < n; c++)
{
newHeaders[c] = dataGridView1.Rows[0].Cells[c].Value.ToString();
if (newHeaders[c] == "A1ORDT")
{
dataGridView1.Columns[c].DefaultCellStyle.Format = "d";
}
}
}
else if (radioButton2.Checked == true)
{
//Add code for custom formatting
}
else
{
MessageBox.Show("Please select standard or custom formatting");
}
}
modified on Friday, April 24, 2009 5:30 PM
|
|
|
|
|
I have a Person class with firstname and lastname properties. I have personList class that contains a list of persons and i have attached it to a listbox. When i display the list box, it grabs the toString() method of person class and displays it. Instead I would like to show the first and last names aligned as two different columns so that it could be viewed better.
I have tried the multi column property, but it takes the next item and puts it in the next column. Can this be achieved in a list box ?
Should i customise the display using the DrawItem event
please let me know.
thanks,
kaer
|
|
|
|
|
Owner drawing may be an alternative, but I think you'd be better if you used a ListView (with the View property set to Detail) or a DataGridView
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn) Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia) Why are you using VB6? Do you hate yourself? (Christian Graus)
|
|
|
|
|
Thanks dave..
Which would be a better alternative..A listview or a DatagridView with respect to performance and ease of use... the data in the list will be around 50 and i wouldnt need any specific features other than displaying the data in columns and handling the selection event
|
|
|
|
|
Having used listviews extensively in an app but only having prototyped the DataGridView, I tend to lean towards the latter.
A list view is a less complex control (it's the file list from windows explorer). A DataGridView is a much more full featured, and complex, grid. If you're databound a DataGridView has native features to populate data. If you're not databound you can still do so easier by doing something like mygrid.addrow(firstItem, secondItem, thirdItem). With a listview afaik you have to create a new row item, use it's addSubItem method to add each value one at a time, and then finally add the row to the grid. There might be gotchas I'm not aware of but the DataGridView seems to be easier to use and has a much richer set of features. If you ever had to do anything fancy in the grid you'll have to use the latter anyway so you might as well start with it.
EDIT: The listview will have semantics somewhat closer to that of the listbox. However it's still different enough that it's not a plug and play replacement.
It is a truth universally acknowledged that a zombie in possession of brains must be in want of more brains.
-- Pride and Prejudice and Zombies
|
|
|
|
|
I"m using this CMT universal tool to migrate emails from Lotus to Exchange. During the migration a lot of outlook reminders boxes popup and once the migration finish, those diaglog boxes won't allow the CMT tool to go to the next user until someone click OK on that diaglog box.
I tried to write an application that get the outlook takes and closes it out, however I don't want to close outlook if there aren't any diaglog boxes there. I'm having a hard time trying to figure out how to write a script that would click close that diaglog box.
|
|
|
|
|
Hi there,
I heard that if we remove even a single byte from an exe file/application (irrespective of its size), then, the entire file/application would disfunction or become an invalid Win32 application. I searched Google, MSDN thoroughly, but did not find any link. So, I thought about consulting you guys. So, please tell me how to remove a byte of an exe file or overwrite its contents with that of my code?
Your help will be truly appreciated,
Thanx,
Rajdeep.NET
|
|
|
|
|
depends which byte you remove i guess, if you remove part of a variable value then it probably wouldnt make a difference, i not sure thou
Life goes very fast. Tomorrow, today is already yesterday.
|
|
|
|
|
1: I don't think to be possible replace some part of an .exe, if you delete,add overwrite some part it becomes invalid.
2: How can you know which byte to replace???
3: Why you need to do that?
|
|
|
|
|
This is not possible because the file basically contains the low-level instructions that are executed. You'd literally have to analyze the file and determine where the binary data that you wish to change is located and then change it.
Hope in one hand and poop in the other; see which fills up first. Hope and change were good slogans, now show us more than words.
|
|
|
|
|
It depends on the executable. Pretty much any application with an activation code will also encrypt/compress or integrity check the exe every time it runs, so changing any byte will make the file useless. Even a lot of applications without an activation code will do the same to make it more difficult to decompile their code.
In the end, it's not easy to do, even if you do find the right file position, it's unlikely to work after a change. And there's probably very few that would help you accomplish it, since most of the time, it's the type of thing that software pirates would be doing, not legitimate programmers.
The true man wants two things: danger and play. For that reason he wants woman, as the most dangerous plaything.
|
|
|
|
|
You should also find that your virus scanner will detect and prevent such things. If it doesn't, change your virus scanner.
No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced.
This message is made of fully recyclable Zeros and Ones
|
|
|
|
|
I have the following collection:
public class PopupWindowItem
{
public Object WindowObject { get; set; }
public UDPWindowType WindowType { get; set; }
public bool AllowMultipleInstances { get; set; }
public PopupWindowItem(Object window, UDPWindowType windowType, bool allowMultiple)
{
this.WindowObject = window;
this.WindowType = windowType;
this.AllowMultipleInstances = allowMultiple;
}
}
public class PopupWindowManager : List<PopupWindowItem>
{
public PopupWindowManager()
{
this.Clear();
}
}
When the user clicks a button to open a window, a new PopupWindowItem is created and populated with the indicated objects. This part woerks fine. Here's the code:
WindowAccountManager accountManager = new WindowAccountManager();
accountManager.Closed += new EventHandler(accountManager_Closed);
m_popupWindowMgr.Add(new PopupWindowItem(accountManager, UDPWindowType.AccountManager, false));
accountManager.Show();
When the application is closed, I traverse the PopupWindowManager collection and close the windows indicated therein. This is where it gets interesting. Here's the code I'm using:
while (m_popupWindowMgr.Count > 0)
{
switch (m_popupWindowMgr[0].WindowType)
{
case UDPWindowType.AccountManager :
{
((WindowAccountManager)(m_popupWindowMgr[0].WindowObject)).Close();
}
break;
}
}
When I call close on the window object inside the PopupWindowItem object, the whole PopupWindowObject is removed from the collection. As you might guess this is unexpected behavior. Why is it doing this?
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
modified on Friday, April 24, 2009 12:15 PM
|
|
|
|
|
Does the function referenced here cause the behavior you are seeing?
John Simmons / outlaw programmer wrote: accountManager.Closed += new EventHandler(accountManager_Closed);
|
|
|
|
|
Seems to be wrong.
|
|
|
|
|
Yep.
God, I'm tired...
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|