Implementing a 410 Status Code Using C#

Here’s how you can setup a 410 Status Code using C#.  Just place this code in the code-behind file in the Page_Load event handler, replacing www.domain_name.com with your domain name, of course:

Response.StatusCode = 410;
if (Request.ServerVariables["SERVER_NAME"].ToString().ToLower() == "www.domain_name.com");
Response.Write("410 Gone");

Leave a Reply