Telerik radgrid 使用 wcf 服务时如何设置 wcf 凭据?
我有一个需要客户端凭据的 wcf 服务,因此我可以通过如下代码进行设置:
wcf.ClientCredentials.UserName.UserName = "用户"; wcf.ClientCredentials.UserName.Password = "密码";
我按照本教程了解如何创建 telerik radgrid 来使用 wcf 服务: http://blogs.telerik.com/blogs/posts/ 09-02-14/openaccess_wcf_and_a_radgrid_oh_my.aspx
但它没有任何有关如何设置凭据的信息。如果有人可以帮助我,我将非常感激!
I have a wcf service that requires client credentials so I can set this via code like this :
wcf.ClientCredentials.UserName.UserName = "user";
wcf.ClientCredentials.UserName.Password = "password";
I followed this tutorial on how to create a telerik radgrid to consume the wcf service:
http://blogs.telerik.com/blogs/posts/09-02-14/openaccess_wcf_and_a_radgrid_oh_my.aspx
But it doesn't have any information on how to set the credentials. If anyone can help I would really appreciate it!!!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
好吧,如果你需要从另一台服务器获取数据,看起来你需要在服务器上创建自己的服务器端类作为ObjectDataSource来作为你的WCF服务的客户端,因为浏览器的跨域限制会阻止RadGrid向两台服务器发出客户端请求。
您的 ObjectDataSource 负责发出 WCF 请求的工作。
以下是有关如何使用 ObjectDataSource 的 Telerik RadGrid 文档:
http://demos.telerik。 com/aspnet-ajax/controls/examples/integration/aspajaxgridapplication/defaultcs.aspx?product=grid
...这是 Microsoft 关于 ObjectDataSource 的文档:
http://msdn.microsoft.com/ en-us/library/system.web.ui.webcontrols.objectdatasource.aspx
OK if you need to get data from another server, it looks like you need to create your own server-side class as an ObjectDataSource on the server to be the client for your WCF service, because the browser's cross-domain restrictions will prevent the RadGrid from making client-side requests to both servers.
Your ObjectDataSource does the work of making the WCF requests.
Here's the Telerik RadGrid docs for how to use an ObjectDataSource:
http://demos.telerik.com/aspnet-ajax/controls/examples/integration/aspajaxgridapplication/defaultcs.aspx?product=grid
...and here's Microsoft's docs on ObjectDataSource:
http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.objectdatasource.aspx
您想在客户端设置凭据,即。使用 Javascript,是这样吗?如果这是正确的,我不知道是否有或应该有一种方法来设置凭据,因为将它们包含在客户端代码中是不安全的。
由于 Web 服务必须与您的网页位于同一域中(由于跨域限制),如果您可以使用正常的 ASP.NET 会话,那么用户就已经通过了身份验证,因为他们已经通过了您的 ASP 的身份验证。 NET应用程序。
这篇博文详细介绍了如何为 WCF 启用“ASP.NET 兼容模式”,这使您的 WCF 服务能够访问会话状态和其他 ASP.NET 内容:
http://blogs.msdn.com/wenlong/archive/ 2006/01/23/516041.aspx
您可以在 WCF 应用程序的配置文件中进行设置:
You want to set the credentials on the client side, ie. with Javascript, is that right campo? If that's right, I don't know if there is or should be a way to set the credentials, because it would be insecure to include them in the client-side code.
Since the web service has to be on the same domain as your web page (because of cross-domain restrictions) if you could use the normal ASP.NET sessions, the user would already be authenticated because they're already authenticated to your ASP.NET application.
This blog post details how to enable "ASP.NET Compatibility Mode" for WCF, which gives your WCF services access to session state and other ASP.NET stuff:
http://blogs.msdn.com/wenlong/archive/2006/01/23/516041.aspx
You set this in your WCF application's config file: