在本地写入文件 ASP.NET

Writing a file locally ASP.NET

我有一个经典的 ASP 脚本,它打开 URL 并生成提供给本地机器的 .gif - 这是 运行 每小时通过计划任务到 'update' gif 适当。这里是 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 
%>

我需要将它转换为 ASP.NET,因为我们最近升级了托管它的服务器(从 2003 年的盒子变成了带有 ASP.NET 的 2012 年的盒子)。

解决此问题的最佳方法是什么?有没有办法在较新的盒子上获得这个经典的 ASP 运行 而无需转换为 ASP.NET?

这不是一个超级复杂的任务,但我无法在网上找到很多,只是将扩展名更改为 .aspx(正如预期的那样,但在某处有人建议)不起作用。

是否有必要完全重写这个?

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

是的。经典ASP可以在Windows Server 2012上启用。网上可以找到很多教程;这是其中之一:

Is it necessary to completely rewrite this?

没有。即使你想从 ASP 转到 ASP.NET,也没有必要完全重写这个:你可以继续使用 MSXML2 库(它仍然存在于较新的 Windows 版本中) ,你只需要学习 VB.NET 并将你的 VBScript 翻译成 VB.NET。这应该很简单。