2

I have a classic ASP script that opens a URL and generates the .gif provided to the local machine - this is ran every hour via scheduled tasks to 'update' the gif appropriately. Here is ourfile.asp:

<% 
'The URL to get our .gif returned
url = "http://api.ourweathersite.com/api/our/api/request"
'Create our xmlhttp request
set xmlhttp = Server.CreateObject("Msxml2.ServerXMLHTTP.6.0") 
xmlhttp.open ("GET", url, false) 
'Send our request
xmlhttp.send
'Create a binary stream of the request and save the .gif
With Server.CreateObject("Adodb.Stream")
    .Type = 1 '1 for binary stream
    .Open
    .Write xmlhttp.responseBody
    .SaveToFile Server.Mappath("\MyIISDirectory\mygif\myresponse.gif"), 2 ' 2 for overwrite
    .Close
End With
set xmlhttp = nothing 
%>

I need to convert this to ASP.NET as we've recently upgraded the server that hosts this (went from 2003 box to a 2012 box with ASP.NET).

What is the best way to go about this? Is there a way to get this classic ASP running on the newer box without converting to ASP.NET?

It's not a super complex task, but I haven't been able to find much online and just changing the extension to .aspx (as expected, but was suggested somewhere) doesn't work.

Is it necessary to completely rewrite this?

Hanny
  • 580
  • 3
  • 16
  • 44

1 Answers1

2

Is there a way to get this classic ASP running on the newer box without converting to ASP.NET?

Yes. Classic ASP can be enabled on Windows Server 2012. A lot of tutorials can be found on the Internet; here is one of them:

Is it necessary to completely rewrite this?

No. Even if you want to go from ASP to ASP.NET, there is no need to completely rewrite this: You can keep on using the MSXML2 library (which is still present in newer Windows versions), you just need to learn VB.NET and translate your VBScript to VB.NET. This should be quite straight-forward.

Heinzi
  • 167,459
  • 57
  • 363
  • 519
  • So just rewrite that above in vb.net (save it as a .vbs?) and run that instead? I have no problem learning asp.net - just didn't know if there was a 'quick & dirty' way to make this work in its existing condition. – Hanny Aug 08 '16 at 15:21
  • @Hanny It's hardly worth the effort could rewrite that in 5 minutes in c# – user692942 Aug 08 '16 at 15:51
  • That file above was just sitting in a flat .asp file - would creating it in C# be the same way? (A flat file with a .cs extension?) a lot of what I've gleaned from online says there are a number of files and encourage using Visual Studio for development of C# - I'm trying to avoid that since this script is so utterly small! Any help appreciated. – Hanny Aug 08 '16 at 16:17
  • @Hanny: Well, the quick and dirty way would be to install (classic) ASP on the server. But yes, ASP.NET also supports [files with inline code](http://stackoverflow.com/q/563585/87698). – Heinzi Aug 08 '16 at 17:36
  • @Heinzi - thanks for the link. I will try with the inline code, as I was having trouble getting an application to deploy properly from Visual Studio. – Hanny Aug 08 '16 at 18:57