Link to home
Start Free TrialLog in
Avatar of Smoerble
SmoerbleFlag for Germany

asked on

How to include external file w. params?

I have an ASPX file.
I can use VB or C# in it.
I want to include the HTML returned by a php file.

So i tried this:
<!-- #Include File="/warplaner/Runner.php?filename=warplaner/newsexport.php&language=de" -->

error message:
"Illegal characters in path."

Please:
How can I include a file with parameters like above?

Thank you.
Smo
Avatar of greenguy
greenguy

Include statements are IIS - and they access the files via the file system, not via HTTP.  So even if there weren't illegal characters in the include statement, you would get the code from the page, not the output.  Here's a link with some more info:

http://dotnetjunkies.com/Forums/ShowPost.aspx?PostID=5481

I have a function that reads a web page via HTTP and returns a string with it's results - it works well for me in these situations:

            public string ReadWebPage( string url )
            {
                  string http = "";

                  if(url.IndexOf("http://")!=0)
                  {
                        url = "http://" + url;
                  }

                  WebRequest objRequest= HttpWebRequest.Create(url);
                  StreamReader sr =  new StreamReader( objRequest.GetResponse().GetResponseStream() );  
                  string result = sr.ReadToEnd();
                  sr.Close();
                  return result;
            }

To use it, just create a label on your page where you want the text to appear, and in your page_Load, put:

Label1.Text = ReadWebPage("SomeUrlWithParameters")

There are a few other ways of reading a web page, and I'm not sure how this compares in performance to other methods, but I've never had a problem.

You can also cache the results of each request, which will minimize the time it takes to get the PHP page contents back on subsequent requests.
Avatar of Smoerble

ASKER

Sorry, I can't get this running.

Can you please give me the full page code? It will be an ASPX page, so I need the language definition and maybe even includes of classes?
ASKER CERTIFIED SOLUTION
Avatar of greenguy
greenguy

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thx a lot greenguy!
I would have rated this posting with a AA++, but unfortunately there's only a normal A possible :D.
Thanks again, this helped so much!

Have fun, bye
Michael
Thanks!