集成 DotNetOpenAuth 和 WCF WebAPI

发布于 2024-11-27 17:25:59 字数 279 浏览 4 评论 0原文

我正在尝试创建基于 WCF Web API 的 RESTful Web 服务。我还需要使用 OAuth 控制访问,为此我使用 DotNetOpenAuth 开源库。

有没有人成功地将两者结合起来?我正在努力将 WCF Web API 的 HTTP 实体表示转换为 DNOA 可以理解的内容(例如 HTTP 请求、HTTP 标头等)。

任何提示将不胜感激。

I am trying to create a RESTful web service based on WCF Web API. I also need to control access using OAuth and for this I am using the DotNetOpenAuth open source library.

Has anyone ever been successful integrating the two? I am struggling converting from the HTTP entities representations of the WCF Web API into something that's understandable by DNOA (e.g. HTTP requests, HTTP headers, etc...).

Any tip would be greatly appreciated.

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

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

发布评论

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

评论(1

埋情葬爱 2024-12-04 17:25:59

你能说得更具体一点吗?

在 WebAPI 中,请求由 HttpRequestMessage 类。响应由 HttpResponseMessage 类。

我以前对 DNOA 没有任何了解,但据我所知,您可以使用 public HttpRequestInfo(string httpMethod, Uri requestUrl、字符串 rawUrl、WebHeaderCollection 标头、Stream inputStream)

HTTP 方法和请求 uri 直接是 HttpRequestMessage 属性。
输入流是通过 Content 属性获取的。我没有看到从 WebAPI 的 HttpRequestHeaders 创建 WebHeaderCollection 的直接方法。但是,您可以迭代 HttpRequestHeaders 条目,然后将其一一插入到 WebHeaderCollection 中。

Could you be a little more specific?

In WebAPI a request is represented by the HttpRequestMessage class. A response is represented by the HttpResponseMessage class.

I've no previous knowledge of DNOA, but from what I saw, you can easily create a HttpRequestInfo from an HttpRequestMessage using the public HttpRequestInfo(string httpMethod, Uri requestUrl, string rawUrl, WebHeaderCollection headers, Stream inputStream).

The HTTP method and request uri are directly HttpRequestMessage properties.
The input stream is obtained via the Content property. I don't see a direct way of creating a WebHeaderCollection from the WebAPI's HttpRequestHeaders. However, you can iterate the HttpRequestHeaders entries and insert then on the WebHeaderCollection one by one.

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