[英]Api Keys in Query String with WCF Data Services
I'm using query string based api keys for my WCF Data Service. 我正在为WCF数据服务使用基于查询字符串的api键。 I can handle this on the server pretty easily -- How would you implement API key in WCF Data Service?
我可以在服务器上轻松处理此问题- 您将如何在WCF数据服务中实现API密钥?
However, how do I send the extra query string arguments from the client, using the Add Service Reference feature of VS2010? 但是,如何使用VS2010的“添加服务引用”功能从客户端发送额外的查询字符串参数? I saw an example for doing it when querying, but certainly not when adding/updating objects.
我在查询时看到了执行此操作的示例,但在添加/更新对象时肯定没有。
You have several options: 您有几种选择:
Add it to the "query string" via .AddQueryOptions ()
通过
.AddQueryOptions ()
将其添加到“查询字符串”
see http://msdn.microsoft.com/en-us/library/cc646860.aspx 参见http://msdn.microsoft.com/en-us/library/cc646860.aspx
and example http://social.msdn.microsoft.com/Forums/en-GB/adodotnetdataservices/thread/226c47f7-f7bc-4450-8dff-e1136e8404ba 和示例http://social.msdn.microsoft.com/Forums/en-GB/adodotnetdataservices/thread/226c47f7-f7bc-4450-8dff-e1136e8404ba
Use DataServiceContext.Credentials
使用
DataServiceContext.Credentials
see http://msdn.microsoft.com/en-us/library/system.data.services.client.dataservicecontext.credentials.aspx 请参阅http://msdn.microsoft.com/en-us/library/system.data.services.client.dataservicecontext.credentials.aspx
and http://msdn.microsoft.com/en-us/library/system.data.services.client.dataservicecontext.aspx 和http://msdn.microsoft.com/zh-CN/library/system.data.services.client.dataservicecontext.aspx
Use the Request header
使用
Request header
see http://msdn.microsoft.com/en-us/library/gg258441.aspx 参见http://msdn.microsoft.com/en-us/library/gg258441.aspx
and http://msdn.microsoft.com/en-us/library/system.data.services.client.dataservicecontext.sendingrequest.aspx 和http://msdn.microsoft.com/zh-CN/library/system.data.services.client.dataservicecontext.sendingrequest.aspx
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.