| | |
combining methods
Thread Solved |
•
•
Join Date: Aug 2008
Posts: 1,162
Reputation:
Solved Threads: 139
are you meaning something like this?
C# Syntax (Toggle Plain Text)
foreach (HtmlElement link in webBrowser1.Document.Links) { bool isValid = false; string linkItem = link.GetAttribute("HREF").ToString(); Uri urlCheck = new Uri(linkItem); WebRequest request = WebRequest.Create(urlCheck); request.Timeout = 10000; // 10 seconds WebResponse response; try { response = request.GetResponse(); isValid = true; Console.WriteLine("Good"); } catch (Exception) { Console.WriteLine("Bad"); //url does not exist } if(isValid) { listViewLinks.Items.Add(link.GetAttribute("HREF").ToString()); } }
Custom Application & Software Development
www.houseshark.net
www.houseshark.net
•
•
Join Date: Oct 2008
Posts: 114
Reputation:
Solved Threads: 0
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.
•
•
Join Date: Aug 2008
Posts: 1,162
Reputation:
Solved Threads: 139
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?
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
www.houseshark.net
•
•
Join Date: Oct 2008
Posts: 114
Reputation:
Solved Threads: 0
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.
•
•
Join Date: Aug 2008
Posts: 1,162
Reputation:
Solved Threads: 139
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
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
www.houseshark.net
•
•
Join Date: Oct 2008
Posts: 114
Reputation:
Solved Threads: 0
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. •
•
Join Date: Aug 2008
Posts: 1,735
Reputation:
Solved Threads: 187
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"
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.
•
•
Join Date: Oct 2008
Posts: 114
Reputation:
Solved Threads: 0
Here is the exception detail.
This is line 73.
C# Syntax (Toggle Plain Text)
System.NotSupportedException was unhandled Message="The URI prefix is not recognized." Source="System" StackTrace: at System.Net.WebRequest.Create(Uri requestUri, Boolean useUriBase) at System.Net.WebRequest.Create(Uri requestUri) 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 at System.Windows.Forms.ToolStripItem.RaiseEvent(Object key, EventArgs e) at System.Windows.Forms.ToolStripButton.OnClick(EventArgs e) at System.Windows.Forms.ToolStripItem.HandleClick(EventArgs e) at System.Windows.Forms.ToolStripItem.HandleMouseUp(MouseEventArgs e) at System.Windows.Forms.ToolStripItem.FireEventInteractive(EventArgs e, ToolStripItemEventType met) at System.Windows.Forms.ToolStripItem.FireEvent(EventArgs e, ToolStripItemEventType met) at System.Windows.Forms.ToolStrip.OnMouseUp(MouseEventArgs mea) at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks) at System.Windows.Forms.Control.WndProc(Message& m) at System.Windows.Forms.ScrollableControl.WndProc(Message& m) at System.Windows.Forms.ToolStrip.WndProc(Message& m) at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m) at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m) at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam) at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg) at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData) at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context) at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context) at System.Windows.Forms.Application.Run(Form mainForm) at linkchecker.Program.Main() in C:\Documents and Settings\sfrider0\My Documents\Visual Studio 2005\Projects\linkchecker\linkchecker\Program.cs:line 17 at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args) at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args) at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly() at System.Threading.ThreadHelper.ThreadStart_Context(Object state) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state) at System.Threading.ThreadHelper.ThreadStart()
C# Syntax (Toggle Plain Text)
WebRequest Request = HttpWebRequest.Create(urlCheck);
Last edited by sfrider0; Dec 2nd, 2008 at 10:22 pm.
![]() |
Similar Threads
- Turtle graph (Python)
- Ever used a methodology for website creativity? (Site Layout and Usability)
- Help with class methods (Java)
- Plz, helping with writing a bit of code. Thanks (C++)
- couple of questions about encapsulation (C++)
Other Threads in the C# Forum
- Previous Thread: Communicating Data Between Forms
- Next Thread: exception pleasehelp
Views: 1836 | Replies: 28
| Thread Tools | Search this Thread |
Tag cloud for C#
.net 2d access algorithm application array asp.net assembly automation barchart bitmap box button c# calendar check checkbox class code color combo control csharp custom data database datagrid datagridview dataset datatable degrees directshow display dll drawing event excel expression file form format forms ftp function gcd gdi+ graphics image index instance interface internet list listbox listener login loop math multithreading mysql notepad office operator outlook2007 picturebox pixel prime print programming query remote remoting resource richtextbox saving search server socket sql sql-server statistics string text textbox threading time timer tutorial update url validation vc++ visual visualstudio webbrowser webcam windows winforms wpf xml






