Topic: Convert this simple PHP to ASP please?

I'm sure it's super easy but I can't find a solution any where... could someone shed some light on how to convert this php script to asp?

<?php

header('Content-type: application/xml');
header("Cache-Control: no-cache, must-revalidate");
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");

$feedurl = $_REQUEST['url'];

if (substr($feedurl, 0, 40) == " *** stripped for this post *** ") {

	$ch = curl_init($feedurl);

	curl_setopt ($ch, CURLOPT_RETURNTRANSFER, true);
	curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, 2);

	$thefeed = curl_exec($ch)
		or die ('could not locate feed');

	curl_close($ch);

} else {

	$thefeed = "Invalid or Non-secure feed";
	
}

echo $thefeed;

?>
Daniel Marino | www.iamdanielmarino.com

Re: Convert this simple PHP to ASP please?

Are you looking for ASP or ASP.NET? If ASP.NET, C# or VB?

Re: Convert this simple PHP to ASP please?

sorry I should have specified that... asp.net vb

Daniel Marino | www.iamdanielmarino.com

Re: Convert this simple PHP to ASP please?

What is the eventual goal of this code? It looks like you're pulling an URL from the querystring and then streaming it in to do something with it. That's not too hard to do, but it matters what you're going to do with it next... What is $thefeed doing?

Re: Convert this simple PHP to ASP please?

I need to parse an xml feed using a jquery plugin, but (from what I understand) JavaScript can only open local files, so this ASP script is acting as a proxy to open a xml feed and creating a string out of it, which the jquery plugin can then parse - does that answer your question?

Daniel Marino | www.iamdanielmarino.com

Re: Convert this simple PHP to ASP please?

Here's a file that will work called "passthrough.ashx"

<%@ WebHandler Language="VB" Class="PassThrough" %>

Imports System
Imports System.Web
Imports System.Xml

Public Class PassThrough : Implements IHttpHandler
    
	Public Sub ProcessRequest(ByVal context As HttpContext) Implements IHttpHandler.ProcessRequest
        
		Dim output As String = ""
		Dim url As String = context.Request.QueryString("url").ToString()
		
		If url <> "" Then
			Dim xmlDocument As New XmlDocument()
			xmlDocument.Load(url)
			output = xmlDocument.InnerXml
		Else
			output = "error"
		End If
		

		context.Response.ContentType = "text/xml"
		context.Response.Write(output)
		
	End Sub
 
	Public ReadOnly Property IsReusable() As Boolean Implements IHttpHandler.IsReusable
		Get
			Return False
		End Get
	End Property

End Class