hello, Add a TextBox, label and a Button on your page and on Button_click try like this:
protected void Button1_Click(object sender, EventArgs e)
{
string url = TextBox1.Text;
WebClient wc = new WebClient();
string html = wc.DownloadString(url);
ArrayList linkCount = CollectLinks(html);
StringBuilder sb = new StringBuilder();
int c = 1;
sb.Append("<table> <tr> <td style="padding-right:40px;"> # </td> <td> URL </td> </tr> ");
foreach (var item in linkCount)
{
sb.Append(" <tr> <td> " + c.ToString() + " </td> <td> " + item.ToString() + " </td> </tr>");
c++;
}
sb.Append("</table>");
lblResult.Text = sb.ToString();
}
public ArrayList CollectLinks(string strSource)
{
ArrayList ar = new ArrayList();
try
{
Regex r1 = new Regex("((http://|www\\.)([A-Z0-9.-:]{1,})\\.[0-9A-Z?;~:&+%#=\\-_\\./]{2,})", RegexOptions.Compiled | RegexOptions.IgnoreCase);
MatchCollection mc = r1.Matches(strSource);
foreach (Match m in mc)
{
ar.Add(m);
}
}
catch (Exception exp)
{
}
return ar;
}
and all links will show in the lable