将后请求作为Web窗体中的API处理 [英] Handling Post Request as API in Web Forms

查看:71
本文介绍了将后请求作为Web窗体中的API处理的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想集中一些代码执行,我已经注意到在我的每个项目中一再重复。





我想要将这个重复的代码集中为在线Web API,而不是添加代码,只想制作一个HTTP请求,然后从它做出响应。



问题:我有一些用于进行一些计算的代码。现在我已经在Web表单中创建了另一个项目,并将该代码放在那里。这是在线example.com/default.aspx。



但我想向它发送一些数据,然后我想检索一个布尔结果,该结果将为true或False。



但是我不知道怎么做。

I want to centralize some code execution which I have noticed repeated again and again in each of my project.


I want to centralize this repeated Code as Online Web API and instead of adding code, just want to make a single HTTP Request and then Response from it.

Problem : I have some code which is used for making some calculation. Now I have created another project in web forms and put that code there. This is online as "example.com/default.aspx".

But I want to send some data to it and then I want to retrieve a boolean result which will either true or False.

But I got stuck how to do it.

推荐答案

用< webmethod>标记方法属性,您可以通过指定其页面和名称来调用它(mypage.aspx / method_name)



您可以通过其参数发送数据(请注意这一点可以是任何包括对象的东西,这样你就可以给它带有所有需要数据的XML或上下文对象)并正常返回该值作为方法返回。
Mark the method with <webmethod> attribute and you'll be able to call it by specifying its page and name (mypage.aspx/method_name)

You can send data via its parameters (note that this can be anything including objects so you can give it XML or context object with all needed data) and return the value normally as return from the method.


这篇关于将后请求作为Web窗体中的API处理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆