Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

create cross domain proxy page with asp.net

Posted on 2009-07-07
6
Medium Priority
?
1,072 Views
Last Modified: 2012-05-07
Hello there,
I create a c# code according the link below to create a proxy page to get info from blip.tv

http://www.experts-exchange.com/Programming/Languages/Scripting/AJAX/Q_23622413.html?sfQueryTermInfo=1+asp.net+cross+domain+proxi

The code I have below works fine to get the details info from blip.tv but get wrong information with the playlist
url for detail list
http://www.blip.tv/file/2331487?skin=json
url for playlist
http://www.blip.tv/bookmarks/1990066?skin=json
Both link retrive correct info from web browser, but with the c# code, play list is not correct.
Any idea? Thanks ahead
string requestcontent;
        string responsecontent;
   
        string request = "http://blip.tv/bookmarks/1990066?skin=json";
        HttpWebRequest req=(HttpWebRequest)WebRequest.Create(request );
        req.Method = "POST";
        req.ContentType = "application/x-www-form-urlencoded";
     
        Stream sw = req.GetRequestStream();
        sw.Write(buffer, 0, buffer.Length);    
        sw.Close();
 
        HttpWebResponse WebResp = (HttpWebResponse)req.GetResponse();
        Stream sr = WebResp.GetResponseStream ();
        StreamReader sdr = new StreamReader(sr);
        responsecontent = sdr.ReadToEnd();
 
        responsecontent = responsecontent.Replace("]);", "]");     
        responsecontent = responsecontent.Substring(16, responsecontent .Length -16);
        Response .Write (responsecontent );
        sdr.Close();
        WebResp.Close();

Open in new window

0
Comment
Question by:tomcattyy
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
6 Comments
 
LVL 21

Expert Comment

by:MogalManic
ID: 24803490
Try changing the Method to Get (line 6).
0
 
LVL 1

Author Comment

by:tomcattyy
ID: 24805835
Hello MoqalManic,
I change the method to Get and get this runtime exception
System.Net.ProtocolViolationException: Cannot send a content-body with this verb-type.
on this line
Stream sw = req.GetRequestStream();
suggestions?
thanks

0
 
LVL 21

Accepted Solution

by:
MogalManic earned 2000 total points
ID: 24806650
Sorry,

I did not examine your sample close enough.  When you use the GET method you don't need lines 7-11(all of the information to request the data is in the URL).  So your code should look like this:
string requestcontent;
string responsecontent;
 
string request = "http://blip.tv/bookmarks/1990066?skin=json";
HttpWebRequest req=(HttpWebRequest)WebRequest.Create(request );
req.Method = "GET";
 
HttpWebResponse WebResp = (HttpWebResponse)req.GetResponse();
Stream sr = WebResp.GetResponseStream ();
StreamReader sdr = new StreamReader(sr);
responsecontent = sdr.ReadToEnd();
 
responsecontent = responsecontent.Replace("]);", "]");     
responsecontent = responsecontent.Substring(16, responsecontent .Length -16);
Response .Write (responsecontent );
sdr.Close();
WebResp.Close();

Open in new window

0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 1

Author Comment

by:tomcattyy
ID: 24808184
Thanks MoqaManic,
I changed as suggest and it works as before. I start to suspect it's the source feed got problem, I send in one playlist number and It returned with all playlist with id=-1, I am contacting the blip.tv now to see if it is their problem.
the query is like below
http://blip.tv/bookmarks/179899?skin=json
I will got correct count in FF but not in IE, so after I place the query in c# code, the result is not correct.
Any input on this?
Thanks
0
 
LVL 1

Author Comment

by:tomcattyy
ID: 24809369
Hello MogalManic,
obviously the json feed got problem, they suggest me to use Rss feed,
I remove some of the returncontent trimming line and I hope to see the whole xml content.
 but after I change the request string to a RSS feed. I got only the content, all  the xml tag was not shown as it should be here, below in code snippet is the one been returned.
Can you see something need to change? Thanks.

<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:creativeCommons="http://backend.userland.com/creativeCommonsRssModule" xmlns:media="http://search.yahoo.com/mrss/" xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:blip="http://blip.tv/dtd/blip/1.0" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:amp="http://www.adobe.com/amp/1.0" xmlns:dcterms="http://purl.org/dc/terms" xmlns:gm="http://www.google.com/schemas/gm/1.1" xmlns:mediaad="http://blip.tv/dtd/mediaad/1.0" version="2.0">
<channel>
<title>tomcattyy : epicProp1 - blip.tv (beta)</title>
<link>http://blip.tv</link>
<description>tomcattyy : epicProp1 - blip.tv (beta)</description>
<language>en-us</language>
<generator>http://blip.tv</generator>
<lastBuildDate>Tue, 07 Jul 2009 20:52:55 +0000</lastBuildDate>
<pubDate>Tue, 07 Jul 2009 20:52:55 +0000</pubDate>

<item>
<guid isPermaLink="false">5600B332-6B37-11DE-8F7C-C8FB9814B35A</guid>
<link>http://blip.tv/file/2331487</link>
<title>property1</title>
<blip:user>tomcattyy</blip:user>
<blip:userid>408432</blip:userid>
<blip:safeusername>tomcattyy</blip:safeusername>
<blip:show>tomcattyy</blip:show>
<blip:showpage>http://tomcattyy.blip.tv/</blip:showpage>

<blip:picture>http://blip.tv/skin/blipnew/placeholder_user.gif</blip:picture>
<blip:posts_id>2351491</blip:posts_id>
<blip:item_id>2331487</blip:item_id>
<blip:item_type>file</blip:item_type>
<blip:contentRating>TV-UN</blip:contentRating>
<blip:rating>0.0</blip:rating>
<blip:datestamp>2009-07-07T20:47:07Z</blip:datestamp>
<blip:language>English</blip:language>
<blip:adChannel/>

<blip:recommendations>0</blip:recommendations>
<blip:recommendable>0</blip:recommendable>
<blip:adminRating/>
<blip:runtime>51</blip:runtime>
<blip:embedLookup>AYGPw2eY91Q</blip:embedLookup>
<blip:embedUrl type="application/x-shockwave-flash">http://blip.tv/play/AYGPw2eY91Q</blip:embedUrl>
<wfw:commentRss>http://blip.tv/comments/?attached_to=post2351491&skin=rss</wfw:commentRss>
<blip:thumbnail_src>Tomcattyy-property1247-316.jpg</blip:thumbnail_src>
<blip:puredescription>House </blip:puredescription>

<blip:smallThumbnail>http://a.images.blip.tv/Tomcattyy-property1247-316-875.jpg</blip:smallThumbnail>
<blip:license>No license (All rights reserved)</blip:license>
<description>

http://blip.tv tomcattyy : epicProp1 - blip.tv (beta) en-us http://blip.tv Tue, 07 Jul 2009 20:52:55 +0000 Tue, 07 Jul 2009 20:52:55 +0000 5600B332-6B37-11DE-8F7C-C8FB9814B35A http://blip.tv/file/2331487 tomcattyy 408432 tomcattyy tomcattyy http://tomcattyy.blip.tv/ http://blip.tv/skin/blipnew/placeholder_user.gif 2351491 2331487 file TV-UN 0.0 2009-07-07T20:47:07Z English 0 0 51 AYGPw2eY91Q http://blip.tv/play/AYGPw2eY91Q http://blip.tv/comments/?attached_to=post2351491&skin=rss Tomcattyy-property1247-316.jpg House http://a.images.blip.tv/Tomcattyy-property1247-316-875.jpg No license (All rights reserved) <embed src="http://blip.tv/play/AYGPw2eY91Q" type="application/x-shockwave-flash" width="480" height="390" allowscriptaccess="always" allowfullscreen="true"></embed> <br /> House http://blip.tv/file/2331487 Default Category Tue, 07 Jul 2009 20:52:55 +0000 <embed src="http://blip.tv/play/AYGPw2eY91Q" type="application/x-shockwave-flash" width="480" height="390" allowscriptaccess="always" allowfullscreen="true"></embed> property1 30FA4B6C-6B31-11DE-A131-99B68C287762 http://blip.tv/file/2331301 tomcattyy 408432 tomcattyy tomcattyy http://tomcattyy.blip.tv/ http://blip.tv/skin/blipnew/placeholder_user.gif 2351289 2331301 file TV-UN 0.0 2009-07-07T20:03:08Z English 0 0 187 AYGPwh2Y91Q http://blip.tv/play/AYGPwh2Y91Q http://blip.tv/comments/?attached_to=post2351289&skin=rss Tomcattyy-mark1854-465.jpg this isthe video1 http://a.images.blip.tv/Tomcattyy-mark1854-465-932.jpg No license (All rights reserved) <embed src="http://blip.tv/play/AYGPwh2Y91Q" type="application/x-shockwave-flash" width="320" height="270" allowscriptaccess="always" allowfullscreen="true"></embed> <br /> <strong>this isthe video1<br /></strong> http://blip.tv/file/2331301 Citizen Journalism korean Tue, 07 Jul 2009 20:53:39 +0000 korean korean <embed src="http://blip.tv/play/AYGPwh2Y91Q" type="application/x-shockwave-flash" width="320" height="270" allowscriptaccess="always" allowfullscreen="true"></embed>mark1

Open in new window

0
 
LVL 1

Author Comment

by:tomcattyy
ID: 24816629
It turned out to be the xml file displayed by browser is like that, all tag will be removed. It's working fine. Thanks.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
Suggested Courses

598 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question