coder net
coder net

Reputation: 3475

asp.net session state from non browser requests

probably a very silly question which you feel like asking on silly days.

A user visits a web page in an ASP.net application from a browser. A session state (and ID) gets established (In proc, db whatever) on the server. Pretty basic.

Now, does this happen if the request originated from a non-browser application, say a console application that does a post and retrieves the response.

Lets say I have a session variable set in the master page. Any page visits will cause this session variable to be set. What happens if a request is programatically issued to grab the response from a page? Is this session variable set or does the console app request have access to session?

According to MSDN, I'm assuming it is only for browser requests?

ASP.NET session state enables you to store and retrieve values for a user as the user navigates ASP.NET pages in a Web application. HTTP is a stateless protocol. This means that a Web server treats each HTTP request for a page as an independent request. The server retains no knowledge of variable values that were used during previous requests. ASP.NET session state identifies requests from the same browser during a limited time window as a session, and provides a way to persist variable values for the duration of that session. By default, ASP.NET session state is enabled for all ASP.NET applications.

Upvotes: 2

Views: 1252

Answers (1)

Steven V
Steven V

Reputation: 16585

If I understand correctly, the console application would be sending a HTTP POST to a web server. If that's the case, your console application is acting like a web browser, and Session is initialized. But ASP.NET normally sends the Session ID using a Cookie, so the browser (or console application) has to store that cookie to continue the session in a future HTTP request to that same HTTP server.

Upvotes: 2

Related Questions