Dopo il sito di ASP Stats Generator, sto rimettendo mano a Weppos.com per convertire l’ultimo progetto ancora in ASP che mi obbliga a tenere in piedi un server Windows (sì, server non hosting).
Non so a voi, ma dopo aver gustato PHP, Java e soprattutto Ruby devo dire che ASP non mi manca per nulla.
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<% Option Explicit %>
<!--#include file="../common.asp"-->
<!--#include file="../../functions/utils.feed.asp"-->
<!--#include file="../../functions/utils.asp-error.asp"-->
<%
Dim strPageName
Dim dtmErrorDate
Dim strErrorTitle
'Dim strErrorSummary
Dim strFunctionSyntax
Dim strErrorContent
Dim strErrorMessageEn
Dim strErrorMessageIt
Dim intErrorViews
Dim strLayout
' Ricava nome pagina e funzione
strPageName = getPageName()
strErrorTitle = convertPageToError(strPageName)
intErrorID = 0
ii = 1
' Richiama informazioni funzione
strSQL = "SELECT * " &_
"FROM tbl_asp_error " &_
"WHERE Showitem = 1 AND Error_title = '" & strErrorTitle & "' "
objRs.Open strSQL, objConn
if not objRs.EOF then
intErrorID = Cint(objRs("Error_ID"))
strErrorTitle = objRs("Error_title")
dtmErrorDate = Cdate(objRs("Error_date"))
strErrorSummary = objRs("Error_summary")
strErrorContent = objRs("Error_content")
strErrorMessageEn = objRs("Error_message_en")
strErrorMessageIt = objRs("Error_message_it")
intErrorViews = Clng(objRs("No_of_views"))
end if
objRs.Close
'
if intErrorID <> 0 then
' Aggiornamento letture
strSQL = "UPDATE tbl_asp_error SET No_of_views = No_of_views + 1 WHERE Error_ID = " & intErrorID
objConn.Execute(strSQL)
else
Set objRs = Nothing
objConn.Close
Set objConn = Nothing
Response.Redirect("default.asp")
end if
' Titolo
strLayout = vbCrLf & "<h2><img src=""/images/icons/folder.gif"" alt=""" & strErrorTitle & """ /> " & strErrorTitle & "</h2>"
' Informazioni
strLayout = strLayout & vbCrLf & "<small>Inserito il " & FormatDateTime(dtmErrorDate, vbShortDate) &_
" - letto " & intErrorViews & " volte</small>"
' Messaggi di errore
if Len(strErrorMessageEn) > 0 then
strLayout = strLayout & vbCrLf & "<div id=""error-message-en"">" &_
"<h3>Messaggio di errore in Inglese</h3>" &_
"<code>" & strErrorMessageEn & "</code></div>"
end if
if Len(strErrorMessageIt) > 0 then
strLayout = strLayout & vbCrLf & "<div id=""error-message-en"">" &_
"<h3>Messaggio di errore in Italiano</h3>" &_
"<code>" & strErrorMessageIt & "</code></div>"
end if
' Contenuto
strLayout = strLayout & vbCrLf &_
"<h3>Da cosa dipende e come risolvere il problema...</h3>" &_
"<p>" & strErrorContent & "</p>"
strPageTitle = strErrorTitle & " | " & arySectionsAsp(1, 5)
strPageTitle2 = strErrorTitle
strPageContent = strLayout
strNavinfoMenu = navyHome("/", true) & navySection("", true, arySections(1, 4), arySections(3, 4)) & navyLevel("default.asp", true, arySectionsAsp(1, 5))
%>
<!--#include file="includes/template.inc.asp"-->
… ad oggi.
def show @error = Error.find(params[:id]) @error.increment!(:nof_views) end
<div id="asperror" class="item"> <!-- start content --> <div class="item-content"> ... </div> <!-- end content --> <div class="item-footer"> ... Views: <strong></strong> Date: <strong></strong> </div> </div>
Ultimamente, un lettore del mio blog mi ha chiesto info su ASP e io ho puntualmente cercato di dare qualche informazione.
Iniziai il mestiere di web developer proprio con ASP, era il 1998/1999, dopo un pò di anni sono passato a PHP a cui va la mia preferenza ancora oggi.
Devo dire che anche a me ASP non manca proprio e non mi è mai mancato…
Beh, direi che il paragone non regge:
nella pagina ASP fai queries, updates, ecc…
Hai provato a fare la stessa cosa con ASP.NET MVC?
Simone, il paragone regge eccome. :)
L’equivalente di queries, update etc che facevo in ASP su Rails corrisponde esattamente all’action indicata sopra che riporto in seguito
Alla riga due richiamo il record dal database con relativi controlli. find infatti lancia una eccezione in caso di RecordNotFound dunque il controllo sulla validità di :id è eseguito in automatico ed in caso di eccezione viene renderizzata la pagina 404.
.increment invece incrementa l’attributo campo nof_views (corrispondente al campo del db per il record in oggetto).
Beh, il paragone continua a non reggere. Ripeto anche io, hai mai provato a usare ASP.NET? Il vecchio asp era una tecnologia progettata prima dell’uscita di .NET. Ora quello che fai te sarebbe qualcosa del tipo
Sulla pagina:
Nel Code Behind, premessa una classe Error
Error.Set(ErrorCode, tbError);
E fine della storia. Error può accedere magari a qualunque tipo di DB, sia esso MySQL, Informix, SQL Server 2005, DB2, e qui finisco di sottolineare come il paragone non regga.