Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles
(untagged)

Another Simple Yahoo Map Proxy

0.00/5 (No votes)
3 Apr 2007 1  
Another Simple Yahoo Map Proxy

Introduction

When alot people try to code their first AJAX code in localhost, "Access Denied" Often pop-up . Therefore, I code up a very simple Yahoo map proxy sample to solve this problem

Background

Got this idea from the simple php proxy by Jason Levitt

Using the code

SimpleDotNetProxy.aspx.cs

using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Net;
using System.IO;
using System.Text;

namespace SimpleDotNetProxy
{
    public partial class simpleProxy : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            string requestString = "";
            string host = "http://api.local.yahoo.com/";
            for (int i = 0; i < Page.Request.QueryString.Count; i++)
            {
                if (!Page.Request.QueryString.Keys[i].Equals("yws_path"))
                {
                    requestString += "&" + Page.Request.QueryString.Keys[i] + "=" + Page.Request[Page.Request.QueryString.Keys[i]];
                }
            }

            host += Page.Request["yws_path"].ToString() + requestString;
            //Response.Write(host);

            //Response.End();

            
            WebRequest request = WebRequest.Create(host);
            WebResponse response = request.GetResponse();
            Stream recieveStream = response.GetResponseStream();
            StreamReader readStream = new StreamReader(recieveStream, Encoding.Default);
            string content = readStream.ReadToEnd();
          
            this.Response.Write(content);



        }

        
    }
}

Remember removing all the tag from the aspx file


License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here