-1

I want that a method will be visible outside my application (web service) and inside it.

So, somethings like this:

[WebMethod]
public static CoordinataTratta TrovaTrattaPiuVicinaByCoordinate(double myLat, double myLng)
{
    ...
    return coordinata;
}

// inside my application
var a = WebService.TrovaTrattaPiuVicinaByCoordinate(0, 0);

can create some problems?

markzzz
  • 47,390
  • 120
  • 299
  • 507

2 Answers2

2

Remember that each call to a web method will be processed in a separate thread in the same process. This means that all static variables will be shared between all threads and hence all calls to the web server. This may lead to hard to reproduce and debug problems.

Just making a method static is probably not a big problem but that can easily lead to using static variables/properties etc. This needs to be avoided in a web server.

Szymon
  • 42,577
  • 16
  • 96
  • 114
0

It's not designed that way. The design is that an instance of the web service class will be created, and then an instance method will be called.

I can only guess why Microsoft designed it that way....

Read more... https://stackoverflow.com/a/1263387/3156647

Community
  • 1
  • 1
tarzanbappa
  • 4,930
  • 22
  • 75
  • 117