简体   繁体   English

在ASP.NET中缓存链接的页面

[英]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. 这将是纯文本的,类似于Google在搜索页面上的“复制”功能。 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. 这样做的目的是确保在不久的将来,我将引用或引用的页面不会从Web上消失。 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? 在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 您的表必须包含2列:1个网址2个页面内容

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;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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