We are doing a old section reskin which is written in classical asp and it is being remade in Asp.net MVC. Content of some of the pages just needs to be pulled into a new layout. So I have written a helper method that basically reads asp file and renders contents in the current view.
public static string readHtmlPage(string url)
{
try
{
string host = HttpContext.Current.Request.Url.Host;
url = "http://" + host + url;
WebResponse objResponse;
WebRequest objRequest = System.Net.HttpWebRequest.Create(url);
objResponse = objRequest.GetResponse();
StreamReader sr = new StreamReader(objResponse.GetResponseStream());
return sr.ReadToEnd();
}
catch (Exception ex)
{
return "If include file cannot be found you will see this message. This is temporary:" + url;
}
}
and its great and works for majority of the pages event when I have to pass the query strings in the urls.
However I have a contact.asp page that is a form that posts to itself to do the validation before sending the e-mail or whatever it does.
Is there a way I can just have it post to the mvc and then pass it the post data?
Currently I am doing this for pages that I need to pass some info to
<%=IncludeHelper.readHtmlPage("/press_room/recent.inc.asp?type="+ ViewData["type_id"]) %>