简体   繁体   中英

Caching linked pages in ASP.NET

I'm thinking of a way of creating a local backup for the pages I will be linking to from my site. This would be text-only, similar to Google's 'Copy' feature on the search pages. The idea is to be sure that the pages I would reference to, or cite from, do not dissapear from the Web in the near future. I know I could just keep local copies, but I will have A LOT of citations.

What would be the best way of achieving this in ASP.NET? Some custom caching in database?

Use this function to get page content and You can save it in your database. your table must contain 2 columns: 1-url 2-pagecontent

static string GetHtmlPage(string PageURL)
{

  String r;
  WebResponse wres;
  WebRequest wreq= HttpWebRequest.Create(PageURL);
  wres= wreq.GetResponse();
  using (StreamReader sr = new StreamReader(wres.GetResponseStream()))
  {
    r= sr.ReadToEnd();
    sr.Close();
  }
  return r;
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM