Powered by MSDN

US - English
NEW! Silverlight 5 is available Learn More

HttpWebRequest or HttpWebResponse doesn't work well in... RSS

35 replies

Last post Nov 04, 2008 12:41 PM by twinae

(0)
  • jjy2

    jjy2

    Member

    354 Points

    155 Posts

    Re: HttpWebRequest or HttpWebResponse doesn't work well in Silverlight 2 beta1

    Mar 15, 2008 04:26 PM | LINK

    I thought you wanted know why response stream is null?

    I just removed Astoria stuff and let the Your default [web service]  page to return string "AAA" and I got "AAA"

    I think IIS 6 should work arlight. if II7 works why not 6?

  • BeSilver

    BeSilver

    Member

    76 Points

    38 Posts

    Re: HttpWebRequest or HttpWebResponse doesn't work well in Silverlight 2 beta1

    Mar 15, 2008 06:33 PM | LINK

    Michael,

    I downloaded the solution and the Button did not even have an Event Handler attached to the Click event. Is the solution supposed to work?! :-)

     

    ------------------------
    blogging @ www.24100.net
  • mchlSync

    mchlSync

    Star

    14968 Points

    2799 Posts

    Re: HttpWebRequest or HttpWebResponse doesn't work well in Silverlight 2 beta1

    Mar 16, 2008 03:20 AM | LINK

    BeSilver

    I downloaded the solution and the Button did not even have an Event Handler attached to the Click event. Is the solution supposed to work?! :-)
     

    :) sorry about that. there were a lot of codes in my application so that I cleaned them up and I think I accidentally remove the event handler.. :)

    I thought you wanted know why response stream is null?
    I just removed Astoria stuff and let the Your default [web service]  page to return string "AAA" and I got "AAA"


    I think IIS 6 should work arlight. if II7 works why not 6?



    Yes. I want to know why response steam is null. but I'm not sure why it doesn't work with Astoria. I'm very sure that Astoria service is working fine since I have tested. maybe, HttpWebRequest or HttpWebResponse are missing some features?

     

    (If this has answered your question, please click on "Mark as Answer" on this post. Thank you!)

    Regards,
    Michael Sync
    Silverlight MVP

    Blog : http://michaelsync.net
  • jjy2

    jjy2

    Member

    354 Points

    155 Posts

    Re: HttpWebRequest or HttpWebResponse doesn't work well in Silverlight 2 beta1

    Mar 16, 2008 03:32 AM | LINK

    mchlsync

    Button did not even have an Event Handler attached to the Click event


    Infact, the button click event is hooked in the code. So the button clearly fires click event.

    Just to clearify what I did was, since what goes to server and also comes back are json string, I just changed your code to send request to default.aspx page without using Astroia.
     
    Then when I run your app using ASP.NET Development Server, you are right, I was dazzling, because I get NULL response stream. But again if you change Content-Type  to something else, you can get response stream with ASP.NET Development Server too.
    One thing I notice is that regardless of MIME type, the request still coming through as I see it in the debugger (Default.aspx page gets called)

    However with the same thing when that App runs on IIS, It work with application/json MIME type.

    I think SL maybe reading MIME type from header when response is returned from server?? Maybe?? And it gives up because you requested json type but it returned OCTET type or something...??

     

  • jjy2

    jjy2

    Member

    354 Points

    155 Posts

    Re: HttpWebRequest or HttpWebResponse doesn't work well in Silverlight 2 beta1

    Mar 16, 2008 04:10 AM | LINK

    Hi Michael,

    I added this to default.aspx, and manually set content type as suggested by the link I posted ealier. and now I get response stream alright with asp.net development server.

    protected override void OnPreInit(EventArgs e)

    {

    Response.ContentType =
    "application/json";

    Response.StatusCode = 200;

    Response.Write(
    "{hello:123}");

    Response.End();

    }

  • jjy2

    jjy2

    Member

    354 Points

    155 Posts

    Re: HttpWebRequest or HttpWebResponse doesn't work well in Silverlight 2 beta1

    Mar 16, 2008 04:29 AM | LINK

    In short, answer to this is to

    1. use IIS

    2. make HTTP Handler or something if you don't have IIS

    I gotta go, fat controller is looking for me

  • jjy2

    jjy2

    Member

    354 Points

    155 Posts

    Re: HttpWebRequest or HttpWebResponse doesn't work well in Silverlight 2 beta1

    Mar 17, 2008 11:28 PM | LINK

    Hi Michael,

    Have you tried your app in IIS yet?
    I am not sure what I suggested was relevant to you,

    Anyhow, It would be nice to hear from you if some hours of my study helped you somewhat.
     

  • mchlSync

    mchlSync

    Star

    14968 Points

    2799 Posts

    Re: HttpWebRequest or HttpWebResponse doesn't work well in Silverlight 2 beta1

    Mar 18, 2008 07:33 AM | LINK

    Hi jjy,

    I haven't tried yet. but I mailed to Yi-lun (Microsoft) about this problem. I'm waiting his reply. I hope he will be able to confirm whether this is a known issue or not.

    Thanks for your solution too. but it's a workaround, right? Hosting Astoria and SL on IIS instead of cassini, using web handler, using xmlhttprequest wrapper might solve the problem but those are workarounds. I would like to know whether this is my mistake in my coding or HttpWebRequest & HttpWebResponse
     are missing something. What do you say?

    (If this has answered your question, please click on "Mark as Answer" on this post. Thank you!)

    Regards,
    Michael Sync
    Silverlight MVP

    Blog : http://michaelsync.net
  • jjy2

    jjy2

    Member

    354 Points

    155 Posts

    Re: HttpWebRequest or HttpWebResponse doesn't work well in Silverlight 2 beta1

    Mar 18, 2008 08:20 AM | LINK


    It's good you did that Michael,
    It's always good to hear a defnite answer and avoid unnecessary workround whenever possible. 

    I read your latest blog, that seems a fine solution too.
    Thanks for letting me know :-)


     

  • mchlSync

    mchlSync

    Star

    14968 Points

    2799 Posts

    Re: HttpWebRequest or HttpWebResponse doesn't work well in Silverlight 2 beta1

    Mar 18, 2008 09:29 AM | LINK

     You are welcomed. jjy. I also like to say "thank you" for all of your replies too. :)

    (If this has answered your question, please click on "Mark as Answer" on this post. Thank you!)

    Regards,
    Michael Sync
    Silverlight MVP

    Blog : http://michaelsync.net