Click here to Skip to main content
15,917,793 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
HTML
 <div class="wrap" style="display:none">
<a href="java<!-- no -->script:loginrecommend();" class="btn-login t-hd">Start Game</a>
 </div>


when i browser other people's website,i View the webpage source ,i want to use my c# winform to run the javascript:loginrecommend(),so that auto to login,maybe use cookie is better.
how can i do?
Posted
Updated 17-Sep-13 4:57am
v2
Comments
Sergey Alexandrovich Kryukov 17-Sep-13 10:58am    
Makes no sense at all. You have no access to "JS code", it is called by a browser. This code cannot live without HTML using it...
—SA
xuyunhai 17-Sep-13 11:05am    
so how can i auto to login? (i don't want to use webBrowser)
[no name] 17-Sep-13 11:11am    
http://www.bing.com/search?q=c%23+auto+login+website
xuyunhai 17-Sep-13 11:30am    
the question isn't simple like search C#+auto+login+website can solve,at least i found but can't solve.
[no name] 17-Sep-13 11:31am    
Well of course it's not that simple.... when you do not even try.

1 solution

Please see my comments to the question, which is at least not clear. The idea to call JavaScript code of the HTML page from outside of the browser simply makes no sense.

Basically, you should do it all in your code, the same thing as the browser does, including authentication. You can use the class System.Net.HttpWebRequest:
http://msdn.microsoft.com/en-us/library/system.net.httpwebrequest.aspx[^],
http://msdn.microsoft.com/en-us/library/system.net.httpwebrequest.credentials.aspx[^].

Please see my past answers:
get specific data from web page[^],
How to get the data from another site[^].

You can find many code samples with authentication, such as:
http://stackoverflow.com/questions/1076015/handling-authentication-with-httpwebrequest-net[^],
HttpWebRequest Credential Authentication[^].

You can find a lot more: http://www.codeproject.com/search.aspx?q=%28HttpWebRequest+OR+HttpRequest%29+authentication&doctypeid=5[^].

—SA
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900