combining methods

Thread Solved

Join Date: Aug 2008
Posts: 1,162
Reputation: dickersonka will become famous soon enough dickersonka will become famous soon enough 
Solved Threads: 139
dickersonka dickersonka is offline Offline
Veteran Poster

Re: combining methods

 
1
  #11
Dec 1st, 2008
are you meaning something like this?

  1. foreach (HtmlElement link in webBrowser1.Document.Links)
  2. {
  3. bool isValid = false;
  4. string linkItem = link.GetAttribute("HREF").ToString();
  5.  
  6. Uri urlCheck = new Uri(linkItem);
  7. WebRequest request = WebRequest.Create(urlCheck);
  8. request.Timeout = 10000; // 10 seconds
  9.  
  10.  
  11. WebResponse response;
  12. try
  13. {
  14. response = request.GetResponse();
  15. isValid = true;
  16. Console.WriteLine("Good");
  17. }
  18. catch (Exception)
  19. {
  20. Console.WriteLine("Bad"); //url does not exist
  21. }
  22.  
  23. if(isValid)
  24. {
  25. listViewLinks.Items.Add(link.GetAttribute("HREF").ToString());
  26. }
  27. }
Custom Application & Software Development
www.houseshark.net
Reply With Quote Quick reply to this message  
Join Date: Oct 2008
Posts: 114
Reputation: sfrider0 is an unknown quantity at this point 
Solved Threads: 0
sfrider0 sfrider0 is offline Offline
Junior Poster

Re: combining methods

 
0
  #12
Dec 1st, 2008
Yeah, that's pretty much what I was meaning. Appears I had that at one time, just not at the same time! That code seems to work, but when I click the "Check Links!" button, I just get "A first chance exception of type 'System.Net.WebException' occurred in System.dll" for the links. I know that the links are good. Sometimes it also says "Bad" also.
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 1,162
Reputation: dickersonka will become famous soon enough dickersonka will become famous soon enough 
Solved Threads: 139
dickersonka dickersonka is offline Offline
Veteran Poster

Re: combining methods

 
0
  #13
Dec 1st, 2008
what are the href's coming in as?

also capitalization

if it also says bad, then the exception didn't occur in that place, what are links coming in as, and what are they being resolved as?
Custom Application & Software Development
www.houseshark.net
Reply With Quote Quick reply to this message  
Join Date: Oct 2008
Posts: 114
Reputation: sfrider0 is an unknown quantity at this point 
Solved Threads: 0
sfrider0 sfrider0 is offline Offline
Junior Poster

Re: combining methods

 
0
  #14
Dec 1st, 2008
In my first code, the links showed up in my listView as "http://www.webpage.com/." Now nothing is showing up in my box. I don't know if that is because it is waiting for it to check all the sites or what. It returned back "Good" on the very first link on the page, which also has the same url as the page that I was checking the links on, but it still didn't show up in my listView. Now every link, every 10 seconds is gives me "Bad", then "A first chance exception of type 'System.Net.WebException' occurred in System.dll" at the same time.
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 1,162
Reputation: dickersonka will become famous soon enough dickersonka will become famous soon enough 
Solved Threads: 139
dickersonka dickersonka is offline Offline
Veteran Poster

Re: combining methods

 
0
  #15
Dec 1st, 2008
i don't know about that trailing / with the .

what is the details on the exception?

try like this
http://msdn.microsoft.com/en-us/library/debx8sh9.aspx
Last edited by dickersonka; Dec 1st, 2008 at 10:46 pm.
Custom Application & Software Development
www.houseshark.net
Reply With Quote Quick reply to this message  
Join Date: Oct 2008
Posts: 114
Reputation: sfrider0 is an unknown quantity at this point 
Solved Threads: 0
sfrider0 sfrider0 is offline Offline
Junior Poster

Re: combining methods

 
0
  #16
Dec 1st, 2008
It doesn't leave the trailing / after the aspx, html, php, or anything else. I tried to check the links on microsoft.com and got an unhandled exceptions error. It said something about their being a wrong uri prefix here WebRequest request = WebRequest.Create(urlCheck); . I also tried adding an extra / and even a /r/n to the link, but it didn't make any difference.
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 1,162
Reputation: dickersonka will become famous soon enough dickersonka will become famous soon enough 
Solved Threads: 139
dickersonka dickersonka is offline Offline
Veteran Poster

Re: combining methods

 
0
  #17
Dec 2nd, 2008
try with httpresponse and httprequest
Custom Application & Software Development
www.houseshark.net
Reply With Quote Quick reply to this message  
Join Date: Oct 2008
Posts: 114
Reputation: sfrider0 is an unknown quantity at this point 
Solved Threads: 0
sfrider0 sfrider0 is offline Offline
Junior Poster

Re: combining methods

 
0
  #18
Dec 2nd, 2008
Tried it, no difference. I changed it back and now I'm getting alot more "Good" links. I still get alot of "first chance exceptions" though.
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 1,735
Reputation: LizR has a spectacular aura about LizR has a spectacular aura about 
Solved Threads: 187
LizR LizR is offline Offline
Posting Virtuoso

Re: combining methods

 
0
  #19
Dec 2nd, 2008
What does the exception say?
Have you allowed for redirection? Eg if you went to www.somesite.com chances are http is telling "hi thats nice for you, now ask for say index.html"
Did I just hear "You gotta help us, Doc. We've tried nothin' and we're all out of ideas" ? Is this you? Dont let this be you! I will put in as much effort as you seem to.
Reply With Quote Quick reply to this message  
Join Date: Oct 2008
Posts: 114
Reputation: sfrider0 is an unknown quantity at this point 
Solved Threads: 0
sfrider0 sfrider0 is offline Offline
Junior Poster

Re: combining methods

 
0
  #20
Dec 2nd, 2008
Here is the exception detail.
  1. System.NotSupportedException was unhandled
  2. Message="The URI prefix is not recognized."
  3. Source="System"
  4. StackTrace:
  5. at System.Net.WebRequest.Create(Uri requestUri, Boolean useUriBase)
  6. at System.Net.WebRequest.Create(Uri requestUri)
  7. at linkchecker.Form1.toolStripButtonLinks_Click(Object sender, EventArgs e) in C:\Documents and Settings\sfrider0\My Documents\Visual Studio 2005\Projects\linkchecker\linkchecker\Form1.cs:line 73
  8. at System.Windows.Forms.ToolStripItem.RaiseEvent(Object key, EventArgs e)
  9. at System.Windows.Forms.ToolStripButton.OnClick(EventArgs e)
  10. at System.Windows.Forms.ToolStripItem.HandleClick(EventArgs e)
  11. at System.Windows.Forms.ToolStripItem.HandleMouseUp(MouseEventArgs e)
  12. at System.Windows.Forms.ToolStripItem.FireEventInteractive(EventArgs e, ToolStripItemEventType met)
  13. at System.Windows.Forms.ToolStripItem.FireEvent(EventArgs e, ToolStripItemEventType met)
  14. at System.Windows.Forms.ToolStrip.OnMouseUp(MouseEventArgs mea)
  15. at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
  16. at System.Windows.Forms.Control.WndProc(Message& m)
  17. at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
  18. at System.Windows.Forms.ToolStrip.WndProc(Message& m)
  19. at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
  20. at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
  21. at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
  22. at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
  23. at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
  24. at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
  25. at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
  26. at System.Windows.Forms.Application.Run(Form mainForm)
  27. at linkchecker.Program.Main() in C:\Documents and Settings\sfrider0\My Documents\Visual Studio 2005\Projects\linkchecker\linkchecker\Program.cs:line 17
  28. at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
  29. at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
  30. at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
  31. at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
  32. at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
  33. at System.Threading.ThreadHelper.ThreadStart()
This is line 73.
  1. WebRequest Request = HttpWebRequest.Create(urlCheck);
Last edited by sfrider0; Dec 2nd, 2008 at 10:22 pm.
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:




Views: 1836 | Replies: 28
Thread Tools Search this Thread



Tag cloud for C#
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2010 DaniWeb® LLC