Does anybody know how can I get IP address of client with RIA services. In WCF we have OperationContext
for that. But it doesn't work with RIA services.
2
votes
2 Answers
1
votes
You can use an Invoke Operation
in your DomainService
to get the IP adress like this:
[Invoke]
public string GetIPAddress()
{
return HttpContext.Current.Request.UserHostName;
}
In the client you should write:
YourContext context = new YourContext();
InvokeOperation invokeOperation = context.GetIPAddress();
invokeOperation.Completed += (s, args) =>
{
if (invokeOperation.HasError)
{
MessageBox.Show("Error");
invokeOperation.MarkErrorAsHandled();
}
else
{
string ip = invokeOperation.Value.ToString();
}
};