404 error page writing to syslog in asp - iis-7

I have a custom 404 page that is written in classic ASP. I am trying to set up that when the page is hit, it should send a log through syslog.
How do I write that out?

You can log events from Classic ASP using:
dim WshShell
set WshShell = Server.CreateObject("WScript.Shell")
wshshell.Logevent 1, "Page not found - your message here!"
set wshshell=nothing
You can find more details, such as the different warning levels on MSDN - Logging Events from ASP.

Related

Session in ASP is not storing values

I have two asp pages in the first page named verify.asp i have write this code:
verify.asp
<%
Username = Request.Form("loginx")
Password = Request.Form("passx")
liberado
Session("liberado") = Username
%>
in the second page i try to use the session variabel "liberado" with any result
barra.asp ,
<%
response.write(session("liberado"))
%>
What i'm making wrong? I m using chrome on IIS of windows 7, Username and Password have values
There was nothing really wrong with your code. Although I can see you've edited it now to remove the dim from liberado, but you've left liberado behind. This means your ASP will try and call a sub called liberado, which presumably doesn't exist. You can go ahead and remove that line.
<%
Dim Username, Password
Username = Request.Form("loginx")
Password = Request.Form("passx")
Session("liberado") = Username
%>
Trying to set a session whilst the session state is disabled will probably result in an error of some kind (and you didn't mention an error in your question). But make sure it's enabled by opening IIS and under ASP > Session Properties set "Enable Session State" to "True".
If it's already true then chances are there's something wrong with your form and the data isn't being posted. On your verify.asp page try running the following code:
for each item in request.form
response.write item & ": " & request.form(item) & "<br>"
next
This will output a list of all the form data being posted.
This could also be a cookie issue. If you're blocking cookies from being set in Chrome then there won't be an ASP session cookie, so session values won't be accessible as you move from page to page.
In Chrome press F12 to open developer tools, click the Applications tab, and from the "Cookies" drop down menu select your domain. Check there's an ASPSESSIONID cookie present, and it's the same cookie on both your ASP pages.
Check the application pool settings in IIS. If there are multiple worker processes active under "maximum worker processes", sessions don't always work. Sessions are stored per process, do if a different worker process handles the second request, the session from the first request might be missing. A setting of "0" means IIS uses as many processes as needed.
More information here

Classic ASP dumping Session Variables (WITHOUT Authentication)

I have inherited an Classic ASP Site and a "bolt-on" ASP.NET site...
NEITHER are using Authentication, BOTH sides have a manual "reinvent-the- wheel" (hard-coded) security system that validates the user/pw from a SQL 2000 database (i.e. "if the user is found via a SQL SELECT, let them in").
New development is in ASP.NET... and they have "integrated" the two sites via ONE login (described above) on the Classic ASP side... then passing a GUID (saved at the time of login to the users record) they validate the GUID on the ASP.NET side ("yes, this is the correct GUID, therefore this is my user... let them in").
Up until now this has been working ONE DIRECTION (Classic ASP to ASP.NET) only with no issues.
(Getting to the problem, bear with me...)
Now they want to perform the same basic design from ASP.NET to Classic ASP by updating the GUID, passing it back, where the lookup validates the user, send them to the correct Classic ASP page... (so the user can return to the Classic ASP side without re-loging-in, previously required) HOWEVER...
***HERE's THE PROBLEM
Session("UserID") is used on the Classic ASP side to (hard code) validate the user... then Response.Redirect is run to send them back to the page that they previously left via "sRedirectToString" ...
'user is found in DB, so send them to the correct page...
Dim sRedirectToString = 'the correct url
Call Response.Redirect (sRedirectToString)
HOWEVER, Session("UserID") gets cleared by IIS or IE (dun'no) and the (hard-coded) validation fails because Session("UserID") is NULL (blank)
Here's the simple (only) validation:
If Trim(Session("UserID") & "") = "" Then
'Session timed out
Response.Redirect('the denied page)
Else
Response.Write "<meta http-equiv=""X-UA-Compatible"" content=""IE=EmulateIE7"">"
End If
So, why are the Session Variables being cleared by a Redirect? (there is no other system authentication is being used).
There is no Session.Abort, nor any specific coding that is clearing Session("UserID").
But when Session("UserID") is tested (see code above) it is found empty and redirects to the DENIED.asp page.
So, hoping there is some property like "PersistSessionVariables" (or something) that I can set so they don't clear...
BUT THEY DO INDEED CLEAR IMMEDIATELY AFTER THE REDIRECT AND THIS IS CONFUSING TO ME.
I appreciate all the Wizards help!

asp Server XML HTTP Object returns nothing

I am new to asp but need to fix a software for a friend. The problem is the routine that uses MSXML2.ServerXMLHTTP to read an .asp page to produce a voucher. I have got it to work and display pages from any server, but when I try to open a page from my own Windows server the routine just returns blank, or hangs the server. Have tried everything. Wonder if it may be related to permissions?
It seems to get stuck in readyState=1.
<%
Response.Buffer = True
Dim objXMLHTTP, xml
Set xml = Server.CreateObject("MSXML2.ServerXMLHTTP")
' Opens the connection to the remote server.
xml.Open "GET", "http://someurl/Testpage.asp", False
' Actually Sends the request and returns the data:
xml.Send
'Display the HTML both as HTML and as text
Response.Write "<h1>The HTML text</h1><xmp>"
Response.Write xml.responseText
Response.Write "</xmp><p><hr><p><h1>The HTML Output</h1>"
Response.Write xml.responseText
Set xml = Nothing
%>
A development server has some restrictions on the amount of requests it can handle simultaneously.
Because you are in the process of executing one server-side script already, the server won't respond to the request you are sending via ServerXMLHTTP.
You can work around this by looking up the worker process for your development website in IIS Manager, and under advanced settings increase the maximum number of worker processes, which is propably set to 1.

Asp.net Response.write only working on local requests

Within my Global.asax file, I have the following that displays a javascript alert message for application exceptions:
Response.Write("<script language='javascript' type='text/javascript'>alert('" + FixJQuotes(ex.Message) + "');</script>");
Response.Write("<script language='javascript' type='text/javascript'>history.back()</script>");
Server.ClearError();
If I access the site via http://localhost/ and generate a purpose made error (hitting a unique index in the database) the application behaves as expected, the browser shows a javascript alert and then goes back a page to show the editing page.
However, if I access the exact same server, but from a different machine, accessing on http://192.168.1.x/ hitting the same exception just results in my custom error page being displayed with no clue as to any errors
I am doing something wrong/ missing something obvious?
Thanks,
Andrew

Application_Error event not being fired with CustomError page in web.config

I have an asp.net website and i have a block of code in my global.asax's Application_Error event to send the error details(stack trace etc..) as an email to my email id.Also i have Custom error page set in my web.config.I published the website in release mode and deployed to production.When i access the site,I got some errors and i was shown the custom error page i set in my web.config.But i never received an email about the error.I am sure the email server is working in production server.I have email sending code in my app which works well. Any thoughts ?
I prefer using http://code.google.com/p/elmah/ for error logging and reporting.

Resources