开发者

how to set wcf credentials when Telerik radgrid consumes the wcf service?

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/0开发者_开发问答9-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!!!


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


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:

<system.serviceModel>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true"/>
</system.serviceModel>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜