I have an ASP.NET (C #) class that is used on both client and server.
Depending on whether the code runs on the client or on the server, it must behave differently.
What is the easiest and most efficient way to find out if the code is executing on the client or server?
Thanks!
unless you are using Silverlight 2 or Silverlight 3. Asp.Net cannot run C # code on client (user's browser)
Runs on the server. If you're not using Silverlight, C # probably won't run on the client.
Unless we're talking about Silverlight here, there is no choice: C # code is always executed on the server, JavaScript is executed on the client.
From your tags I can see that you are talking about a web application and not a winforms client-server.
If it's in javascript, html and css, or silverlight, it happens in the browser. If it happens in C #, it happens on the server.