如何模拟.NET HTTP响应?

发布于 2025-02-06 18:05:00 字数 203 浏览 2 评论 0原文

我正在开发一个C#.NET框架应用程序,该应用程序必须从JSON格式中的不同设备中解析状态协议。 这些协议是通过HTTP请求(System.net.Webrequest和.Response)获得的。我没有机会直接从设备接收这些协议,但是我有技术规范。因此,我需要模拟响应。 我该如何测试:我需要一个URL,可以在其中存储JSON数据,以及可以接收并将这些数据加载到Applicaton的地方。

I’m developing a C# .NET Framework application which has to parse status protocols from different devices in the JSON format.
These protocols are obtained via http requests (System.Net.WebRequest and .Response). I don’t have the opportunity to receive these protocols directly from the devices, but I have a technical specification. So I need to simulate the response.
How can I test this: I need a URL where I can store my JSON data and from where I can receive and load this data into my applicaton.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

韵柒 2025-02-13 18:05:00

您可以只读取从文件中的jsons来“模拟”响应。如果您想制作HTTP重新要求,则必须使用模拟的API。为此,您可以尝试 Mocky 。只需单击网站上的新模拟,然后创建自定义模拟的API即可。您将获得一个URL,可以使用您配置的标头和数据响应。

You can just read the JSONs from a file(s) to "simulate" a response. If you want to make HTTP-Requests then you have to use a mocked API. For this purpose you can try Mocky. Just click on NEW MOCK on the website and create your custom mocked API. You will get an URL that will response with the headers and data that you configured.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文