Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8608261
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T03:33:53+00:00 2026-06-12T03:33:53+00:00

I am using using a Proxy file to allow our system to use ajax

  • 0

I am using using a Proxy file to allow our system to use ajax to load in pages from an a different subdomain of our system. I successfully did this with my first attempt, but my second attempt is giving me an error, and I’m struggling to work out why, any help would be appreciated.

Firstly this is my Proxy.aspx.cs:

protected void Page_Load(object sender, EventArgs e)
{
    string proxyURL = HttpUtility.UrlDecode(Request.QueryString["u"]);

    if (proxyURL != string.Empty)
    {
        HttpWebRequest request = (HttpWebRequest) WebRequest.Create(proxyURL);
        request.Method = "POST";
        request.ContentLength = 0;
        HttpWebResponse response = (HttpWebResponse) request.GetResponse();

        if (response.StatusCode.ToString().ToLower() == "ok")
        {
            string contentType = response.ContentType;
            Stream content = response.GetResponseStream();
            if (content != null)
            {
                StreamReader contentReader = new StreamReader(content);
                Response.ContentType = contentType;
                Response.Write(contentReader.ReadToEnd());
            }
        }
    }
}

My HTML/Javascript is just this:

<script>
    $(document).ready(function () {
        $.ajax({
            type: "POST",
            url: "Proxy.aspx?u=<%=GetUrl()%>",
            success: function (data) {
                $('#iFrameHolder').html(data);
            }
        });
    });
</script>

<div id="iFrameHolder"></div>

Then I just use the GetUrl() function to build the url of whatever page I require from the project on the subdomain.

I got this working no problem at all with one url, but for the second attempt I received this error:

System.Net.WebException: The remote server returned an error: (404) Not Found.     
at System.Net.HttpWebRequest.GetResponse()     
at G2F.Collective.WebApplication.Shared.Proxy.Page_Load(Object sender, EventArgs e) 
in D:\My Documents\Firefly\Collective\Dev\Solution\WebSites\G2F.Collective.WebApplication\Shared\Proxy.aspx.cs:line 26     
at System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e)     
at System.Web.UI.Control.LoadRecursive()     
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

That to me would suggest something was wrong with my url being built, but using Chrome’s web developer tools I can copy out the exact querystring being passed to the proxy, paste it into the browser address bar, and visit the page without any issue at all, which means there is no issue with the url being built. So I have no idea why this one returns a 404. If anyone can give me any suggestions, I’d greatly appreciate it.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T03:33:55+00:00Added an answer on June 12, 2026 at 3:33 am

    With the help of the suggestion by Darwish I discovered what I needed to do was change the web request to GET instead of POST, making my Proxy file look like this:

    protected void Page_Load(object sender, EventArgs e)
    {
        string proxyURL = HttpUtility.UrlDecode(Request.QueryString["u"]);
    
        if (proxyURL != string.Empty)
        {
            HttpWebRequest request = (HttpWebRequest) WebRequest.Create(proxyURL);
            request.Method = "GET";
            request.ContentLength = 0;
            HttpWebResponse response = (HttpWebResponse) request.GetResponse();
    
            if (response.StatusCode.ToString().ToLower() == "ok")
            {
                string contentType = response.ContentType;
                Stream content = response.GetResponseStream();
                if (content != null)
                {
                    StreamReader contentReader = new StreamReader(content);
                    Response.ContentType = contentType;
                    Response.Write(contentReader.ReadToEnd());
                }
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using svcutil to generate a proxy file for use against a service
I'm using tornado to fetch many web pages asyncroniously using HTTP proxy . So,
I have generated a proxy class from a wsdl file (C# VS 2008) The
Say I use php copy(), to get a file from a site. And then
I am communicating with a partner's webservice using proxy classes they've provided. I have
I'm writing a proxy using .NET and C#. I haven't done much Socket programming,
I have problems with running CAS using the proxy mode. However, I don't have
I am trying to consume a WCF Webservice on Mono using the proxy but
I have an application that is working as a proxy using QTcpSocket to intercept
Are there any ways to mock a WCF client proxy using Rhino mocks framework

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.