ASP.NET

Moderators: None (Apply to moderate this forum)
Number of threads: 1727
Number of posts: 3292

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
Encapsulate a page "classic asp" inside a page "aspx" Posted by eduardolucioac on 15 Oct 2012 at 7:12 AM
I have a question at least interesting! Gentlemen, it is possible to encapsulate a page "classic asp" inside a page "aspx"? The goal is to receive the output (text) of a legacy "classic asp" and places it inside a page "aspx". In this case (more specifically) I want to get the return of our "classic asp" as text, modify it and then return my "classic asp" inside the page "aspx". Can I do it when the request is by "GET", but by "POST" error occurs!

Apparently this problem is conceptual and has no way to capture the requests "POST" and redirect them to the page encapsulated. However, I wanted an opinion from an expert! My hypothesis is that if the requests via "POST" follow a pattern for any type of technology, it seems right that I can simply redirect that request "raw" to another page without worrying about its content.

Below I put some code snippets that I used in my attempts to illustrate.

private WebClient sessionWebClient
{
get
{
if (Session["sessionWebClient"] == null)
{
Session["sessionWebClient"] = new WebClient();
}
return (WebClient)Session["sessionWebClient"];
}
}

protected void Page_Load(object sender, EventArgs e)
{

string retrieveHttpContentHolder = "";

sessionWebClient.Headers.Clear();
var headers = String.Empty;
if (Page.Request.HttpMethod == "POST")
{
foreach (var key in Request.Headers.AllKeys)
{
headers += key + "=" + Request.Headers[key] + Environment.NewLine;
sessionWebClient.Headers.Add(key.ToString(), Request.Headers[key].ToString());
}
}

retrieveHttpContentHolder = RedirectRequests.PostUrl(sessionWebClient, Page.Request.HttpMethod,
"http://localhost/goldendoc/login.asp",
Request.QueryString.ToString() +
Request.Form.ToString());

retrieveHttpContentHolder = retrieveHttpContentHolder.Replace("/goldendoc", "");
retrieveHttpContentHolder = retrieveHttpContentHolder.Replace("image.asp", "image.aspx");
retrieveHttpContentHolder = retrieveHttpContentHolder.Replace("login.asp", "login.aspx");

Response.Write(retrieveHttpContentHolder);

}

public static string PostUrl(WebClient webClientHolder, string GETorPOST, string url, string what)
{

byte[] byteArray = default(Byte[]);

if (!string.IsNullOrEmpty(what) && GETorPOST == "GET")
{
url = url + "?" + what;
}
else if(GETorPOST == "POST")
{
Encoding.ASCII.GetBytes(what);
}

Byte[] bResult = default(Byte[]);

if(GETorPOST == "POST")
{
bResult = webClientHolder.UploadData(url, GETorPOST, byteArray);
}
else if(GETorPOST == "GET")
{
bResult = webClientHolder.DownloadData(url);
}

Encoding objEncoded = Encoding.GetEncoding("utf-8");

if (bResult != null)
{
return objEncoded.GetString(bResult);
}

return null;

}



 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.