Reputation: 38023
I have an ASP.NET (C#) class that is used both on the client and server.
Depending on whether the code is being executed on the client or the server, it needs to behave differently.
What is the simplest & most efficient way of telling if the code is executing on the client or the server?
Thanks!
Upvotes: 0
Views: 116
Reputation: 33143
By your tags I see your talking about a web application not a client-server winforms app.
If it is in javascript, html and css, or silverlight it's happening in the browser. If it is happening in C#, it's happening on the server.
Upvotes: 2
Reputation: 115779
Unless we're talking Silverlight here, there's not much choice: C# code is always executed on the server, JavaScript is executed on the client.
Upvotes: 2
Reputation: 422036
It's executing on the server. Unless you are using Silverlight, C# is probably not run on the client.
Upvotes: 2
Reputation: 3491
unless you are running Silverlight 2 or Silverlight 3 There is no way for Asp.Net to run C# code in the client (the users' browser)
Upvotes: 3