Click here to Skip to main content
15,887,477 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hey,

I'm new to the ASP .NET technology (but much acquainted to other .NET technologies like C#). I would like to know whether (and how) is it possible to execute C# code simply when the page loads, given all the relevant data from the HTTP request (pass POST information to it). and simply write the returned string back in the HTTP response.

Thanks a lot for helping.
Posted
Comments
n.podbielski 13-Oct-12 8:51am    
On server side or client side?
Do you mean like web page will load in browser? Then you want to run some server code?
ShacharK 13-Oct-12 9:04am    
I would like to write minimal amount of ASP code.
I have no real need for any web features provided by the HTTP protocol.
I use the http server as a platform to have clients communicating with my database using my custom JSON-based protocol.
You send a request, My protocol which I want to implement in C# processes information, makes the desired API Calls, and prints out a simple JSON-object response (instead of an actual website's html)
thewazz 13-Oct-12 10:18am    
this help? http://social.msdn.microsoft.com/search/en-us?query=request
n.podbielski 13-Oct-12 14:35pm    
Then why wont you just use JSON enabled WCF service?
ShacharK 14-Oct-12 16:12pm    
Would that be better? Isn't WCF an overkill? I always found this technology far too complicated for any of my needs in the past. I would love to hear your opinion.

1 solution

Hi,
The simple approach: in Page_Load event (pertinent to ASP.NET server side) use !IsPostBack property that indicates the first page load.

Read more on this topic here: http://stackoverflow.com/questions/5364375/page-load-vs-onload[^]

Regards,
AB
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900