0

I'm trying to make use of web services in an ASP.NET application I'm developing; currently I have a service running that I call form the client side to run AJAX queries against my database as textboxes are updated. This all works a treat. I am using the ASP.NET ScriptManager not jQuery ajax or any other third party tools.

I also need to make use of the logic in the web service elsewhere in the application - specifically if the page that uses it from the client gets posted back to the server (if a drop-down is changed) a lot of the calculated values need to be changed. It seems silly to duplicate the code in code-behind - is there a way I can access the existing service to do the calculations?

I've had a look at some other questions, but they talk a lot about SOAP, REST, Endpoints and Bindings, and I really don't understand a word of it! Some general advice or a pointer in the right direction would be great.

4

2 回答 2

1

最简单的解决方案可能是将 Web 服务中的相关代码分解到类库中。然后您可以从您的 Web 服务器引用这个新的类库并在回发期间调用这些方法。

于 2013-09-04T16:02:36.303 回答
0

我认为您应该将 Web 方法的逻辑提取到另一个类中的另一个函数中,然后在您的 Web 方法和代码隐藏中重用该函数。

于 2013-09-04T21:29:29.657 回答