Adam Rackis
Adam Rackis

Reputation: 83356

Access HttpContext of Silverlight page in asmx service

I'm sorry if this has been asked - I can't seem to find it if so.

If I have a silverlight 4 page calling a plain old asmx web service, is there a way to access the http context of the aspx page hosting my silverlight from the asmx WebMethod?

HttpContext.Current seems to relate to the call to the service (the path property is the path to the asmx file) and so HttpContext.Current.Request.QueryString (what I'm really after) is empty.

Upvotes: 1

Views: 1991

Answers (2)

scartag
scartag

Reputation: 17680

You could pass the QueryString object as a parameter to the asmx service.

from silverlight you can get the query string of the host page using the code below.

var queryString = System.Windows.Browser.HtmlPage.Document.QueryString;

var id = System.Windows.Browser.HtmlPage.Document.QueryString["id"]; //if u want a specific item

Hope this helps

Upvotes: 2

Viktor
Viktor

Reputation: 486

No, you can only access the context of the current call. What you need to do is send the information that you are interested in, the query string (or parts of it), to your web service method as a parameter.

Upvotes: 1

Related Questions