Thursday, August 22, 2013

500 – Internal server error from IIS 7.5 on Windows 2008 R2

You are running an ASP or ASP.NET web application on IIS on Windows 2008 R2 from a remote web browser and you constantly see following error message.
SNAGHTML839201
While this is the proper results for a production server (you never want to show remote users the details of an error), it is not helpful while testing a new installation…as a developer you need to see the error messages on the remote browser. There is an obscure setting that controls this for both ASP and ASP.NET. I hope the following will help anyone needing to see error details on a remote connected browser.

For Classic ASP Errors

In IIS Manager, select your ASP site, the double-click the ASP icon in the IIS section. The configuration settings for this ASP applications will appear. Open the section for Debugging and make sure the option Send Errors to Browser is set to True. Review other settings while you are here to ensure they match want you want.
SNAGHTML8bec9e

For Classic ASP and ASP.NET Errors

Just making the change above seems to work find under IIS on Windows 7 but not Windows 2008 R2. You may need to change one other setting. In IIS Manager, select the ASP or ASP.NET site, the double-click the Error Pages icon in the IIS section (do not confuse with the .NET Error Pages in the ASP.NET section) . The list of error codes and related IIS Error Pages will appear. Select the one for 500 errors and right-mouse, then choose Edit Feature Settings from the popup menu.
SNAGHTML94342f
The default settings is the third option which only allows detailed errors to be sent to a browser on the same server. Change this setting to the second option labeled Detail errors and then details of your code or script errors will be sent to the browser even if it is a remote quest. If you are using Internet Explorer, also make sure that Show Friendly Errors is not enabled. This is not a problem for Firefox users.
SNAGHTML962958
Be sure and change this setting back to the default if and when the server is used in a production environment. When that is the case, use the NT Event log for ASP errors (also set in the ASP settings section) and .NET Error Tracing as better ways to view the details of production errors. Hope this helps! Now you can view ASP and ASP.NET errors in the browser remotely. Here is an example of a Classic ASP error.
SNAGHTML9ccb57

Friday, August 9, 2013

PHP: give alert popup then redirect the page

Do something like
header("Location: index.php?Message=" . urlencode($Message));
Then on index.php...
if (isset($_GET['Message'])) {
    print $_GET['Message'];
}
Reference: http://stackoverflow.com/questions/11703854/php-give-alert-popup-then-redirect-the-page