Dot Freelancer
Dot Freelancer

Reputation: 4253

get html response from local aspx page

I have local .aspx page to generate HTML message. But when I try to request the page using this code

 HTML = new WebClient().DownloadString("http://localhost/MySite/HTMLEmail.aspx") 

it returns the HTML without the passed data through Session. If I tried to request the page directly from the browser, it displays html page with the passed data.

so why it doesn't fill the HTML message with the data when i programmatic request the page ?

Upvotes: 0

Views: 658

Answers (2)

David
David

Reputation: 219057

it returns the HTML without the passed data through Session

Not if that's the only request being made, it doesn't. Session is used to track data across multiple requests made by a particular client. (Effectively creating a server-side "session" for that client.) If you're only requesting one page one time then there's no session state to be tracked in the first place.

If you're making other requests (not shown in the question) and the server-side application isn't tracking session state properly then the problem may be in the server-side application, not necessarily in the client.

If you're making other requests as another client then that's a completely different session. Different clients can't access each other's session state (for fairly obvious reasons).

Upvotes: 1

sm.abdullah
sm.abdullah

Reputation: 1812

i do not know how the session state is being created or maintained. if your data uses a session variables which was created by an earlier request then you need to follow the request sequence with webclient too by using a special kind of webclient extended class. you may follow this post. How do I log into a site with WebClient?

Upvotes: 0

Related Questions