Articles

Affichage des articles du novembre, 2011

ASP.NET custom 404 returning 200 OK instead of 404 Not Found

Image
ASP.NET provides a simple yet powerful way to deal with errors that occur in your web applications. We will look at several ways to trap errors and display friendly meaningful messages to users. We will then take the discussion a step further and learn how to be instantly notified about problems so you can cope with them right away. As a geek touch we will also track the path 404's travel. 1. Edit the web.config for custom errors: < customErrors mode = "On" >   < error statusCode = "404" redirect = "~/404.aspx" /> </ customErrors > 2. Add a 404.aspx page and set the status code to 404. public partial class _404 : System . Web . UI . Page {     protected void Page_Load ( object sender , EventArgs e )     {         Response . StatusCode = 404 ;     } } Now, if I go to a page extension that is processed by ASP.NET and does not exist, my "Live HTTP header" addon in Firefox shows a 404. H

Blocking IP address range using Microsoft IIS

You need to select the "Group of computers" option instead of the default "Single computer" option in the "Deny Access" dialogue. When this is selected, an additional group of text boxes appears to the right of the IP Address box, into which you can put a netmask. So, to block 194.*.*.* you put 194.0.0.0 into the left-hand set of boxes and 255.0.0.0 into the right-hand set. The zeros after 194 could have any value as they are ignored based on the netmask. Netmasks basically indicate which bits of the IP address are relevant, so in this case the "255" says that the whole first part of the IP address you entered ("194") is relevant and the "0"s say that the other 3 parts are not. So, the rule is "block any IP that starts with 194 and has anything else following that".

ASP.net Tab missing in IIS 6 on 64-bit Windows 2003 Server

A few days ago, I add to migrate an ASP.NET 4 website to an old Windows 2003 x64 server, which is setup to use IIS in 32-bit mode. Apparently there is a bug (MS will call it a feature) which hides the ASP.NET tab in IIS when you have this particular configuration. So long story short, to switch my individual site over to ASP.net 4.0 I had to use aspnet_regiis to manually set the framework version for that one site. Here's how to do: First you have to find the website IIS path. Go into IIS, under the website properties under the "Website" tab there is the Logging section. Click on and right click on the "Properties" button. This will bring up the "Logging Properties" dialog which lists the name of the website at the bottom next to "Log file name" eg. W3SVCXXXX. Make a note of this. Open a command prompt to the c:\windows\Microsoft.net\Framework\v4.0.30319\ folder of your choice. (v2.x, or v4.x) Run aspnet_regiis -lk (that's -LK) th

How to flip an image with CSS3

Yes, you can flip images with CSS! Possible scenario: having only one graphic for an arrow, but flipping it around to point in different directions. img.arrow {     -moz-transform: scaleX(-1);   -o-transform: scaleX(-1);   -webkit-transform: scaleX(-1);   transform: scaleX(-1);   filter: FlipH;   -ms-filter: "FlipH"; }