2

I have, in my silverlight application, a call to a aspx page, to create and register a txt file on a directory.

Uri ub = (new Uri(HtmlPage.Document.DocumentUri, "GenereInfos.aspx?&connexion=" + connexion + ";&id=" + this.Id));

        if (HtmlPage.IsPopupWindowAllowed)
        {
            HtmlPopupWindowOptions opt = new HtmlPopupWindowOptions();
            HtmlPage.PopupWindow(ub, "file", opt);
        }
        else
        {
            HtmlPage.Window.Navigate(ub);
        }

I have to go trough my aspx page to generate my txt file, because silverlight don't allow it.

The problem here is, a popup will appear, or the page will load the new uri.

What I want is call the code inside the asp only(which works perfectly), without loading the uri.

Is there a way to do this?

Edit : After DGibbs answer, there is another question now :

WShy can't I use GetResponse() in there?

HttpWebRequest req = (HttpWebRequest)HttpWebRequest.Create(new Uri
                     (HtmlPage.Document.DocumentUri, "GenereInfos.aspx?&connexion=" + connexion + ";&idPocedure=" + itmProcedure.IdProcedure));
            string response = new System.IO.StreamReader(req.GetResponse().GetResponseStream()).ReadToEnd();

Here a little answer : Silverlight is asynchrnous, so, we can't call GetResponse who is synchronous.

So, the best way to call my aspx page, is to use WebClient found here

provençal le breton
  • 1,428
  • 4
  • 26
  • 43

1 Answers1

0

You could just use WebRequest:

HttpWebRequest req = (HttpWebRequest)WebRequest.Create(new Uri
                     (HtmlPage.Document.DocumentUri, "GenereInfos.aspx?&connexion=" + connexion + ";&id=" + this.Id));
string response = new System.IO.StreamReader(req.GetResponse()
                 .GetResponseStream()).ReadToEnd();
DGibbs
  • 14,316
  • 7
  • 44
  • 83