paladyn3012
New Member
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:\[code\]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()); } } }}\[/code\]My HTML/Javascript is just this:\[code\]<script> $(document).ready(function () { $.ajax({ type: "POST", url: "Proxy.aspx?u=<%=GetUrl()%>", success: function (data) { $('#iFrameHolder').html(data); } }); });</script><div id="iFrameHolder"></div>\[/code\]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:\[code\]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)\[/code\]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.