Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C# - Can WebMethodAttribute adversely effect performance?

I just noticed my Excel service running much faster. I'm not sure if there is an environmental condition going on. I did make a change to the method. Where before it was

class WebServices{
[ WebMethod( /*...*/) ]
public string Method(){}
}

Now its attribute is removed and the method moved into another class

class NotWebService {
public string Method(){}
}

But, I did this because the Method is not called or used as a service. Instead it was called via

WebServices service = new WebServices();
service.Method();

and inside the same assembly. Now when I call the method

NotWebService notService = new NotWebService();
notService.Method();

The response time appears to have gone up. Does the WebMethodAttribute have the potential to slow local calls?

like image 385
P.Brian.Mackey Avatar asked Nov 04 '22 19:11

P.Brian.Mackey


1 Answers

Indeed the WebMethod attribute adds a lot of functionality in order to expose the method through a XML WebService.

Part of the functionality that causes overhead are the following features considered as part of the configurable stuff for a web method:

  • BufferResponse
  • CacheDuration
  • Session Handling
  • Transaction Handling

For more information just check the WebMethod attribute documentation

Regards,

like image 118
wacdany Avatar answered Nov 09 '22 05:11

wacdany