I am trying to write code for a class that is able to download the page source of a web page. However, for pages that contain AJAX elements, the request comes back without them. Here is the code I have so far:

Code:
'''<summary>Gets the page source of a page located at the specified Url</summary>
Function PageSource(ByVal Url As String) As String
Dim req As System.Net.WebRequest = System.Net.WebRequest.Create(Url)
Dim res As System.Net.WebResponse = req.GetResponse
Dim reader As New System.IO.StreamReader(res.GetResponseStream)
Return reader.ReadToEnd
End Function
This code works awesome for simple pages, but how is one supposed to read the page source within an AJAX element? Basically I need the WebRequest to render the AJAX element before returning the stream. Is a WebRequest the correct way to do this, or should I be using another method to get the page?

I'm sure the solution is simple, I just haven't been able to find any information on it at all. So any hints, tips, or partial answers would be most helpful.