我尝试从 C# 中的 API 调用自定义协议应用程序。
我的自定义协议已安装,我可以在浏览器中使用“my-app://myParams”URI 调用它,但我不知道如何使用 webrequest 调用自定义 URL。我试图添加一个实现 IWebRequestCreate 并调用它的新对象,但我有 stackoverflow 错误。
WebRequest.RegisterPrefix("my-app", new MyCustomWebRequestCreator());
WebRequest req = WebRequest.Create("my-app:");
internal class CustomWebRequestCreator : IWebRequestCreate
{
WebRequest IWebRequestCreate.Create(Uri uri)
{
return WebRequest.Create(uri); // what can I do here ?
}
}
使用最后一个代码,我的 WebRequest.Create(uri) 方法上有一个 stackoverflow 异常,但我不知道在这个方法中要做什么。
谢谢你的帮助