C#webclient:无法读取ajax html内容

时间:2013-01-29 07:56:58

标签: c# ajax webclient

我想创建一个HttpModule来为google bot生成html快照,我的代码是:

private void Application_BeginRequest(Object source, EventArgs e)
{
    // Create HttpApplication and HttpContext objects to access
    // request and response properties.
    var application = (HttpApplication)source;
    HttpContext context = application.Context;

    string escapedFragment = HttpContext.Current.Request.Params["_escaped_fragment_"];

    if (!string.IsNullOrWhiteSpace(escapedFragment))
    {
        string result = string.Empty;
        using (var client = new WebClient())
        {
            Stream data = client.OpenRead("http://giadinhthinhvuong.com/#/" + escapedFragment);
            if (data != null)
            {
                var reader = new StreamReader(data);
                result = reader.ReadToEnd();
            }
        }
        context.Response.Write(result);
    }
}

但是它似乎无法在网页中使用ajax内容。

Here您可以找到我的链接测试。

所以我的问题是:

  1. 是否有其他方法可以为C#生成html快照?
  2. 或者还有其他方法可以在C#中读取ajax内容吗?

0 个答案:

没有答案