How to add starfield validation to titanium sites

Add new starfield.ashx file

In the site root folder (typically server/tld/domain/www) create a file called starfield.ashx. Add the following code to the file:

<%@ WebHandler Language="C#" Class="StarfieldHandler" %>

using System.Web;
using TitaniumCore.Models;

public class StarfieldHandler : IHttpHandler
{
	public void ProcessRequest(HttpContext context)
	{
		// Get the "starfield" configuration entry from the database
		TitaniumCore.Models.Configuration starfieldConfig = TitaniumCore.Models.Configuration.GetConfigurationEntry("starfield");

		// Output the configuration value as plain text
		if (starfieldConfig != null)
		{
			context.Response.ContentType = "text/plain";
			context.Response.Write(starfieldConfig.Value);
		}
		else
		{
			context.Response.StatusCode = 404;
			context.Response.Write("Starfield configuration not found.");
		}
	}

	public bool IsReusable
	{
		get { return false; }
	}
}

Update global.asax.cs

in the SetAppRoutes() method add the following line of code above the line with the following comment:
//Adds the Ignore Routes:

	
		RouteTable.Routes.IgnoreRoute(".well-known/{*pathInfo}"); // Ignore .well-known requests so the CMS doesn't handle them
	

In the Application_BeginRequest method and after the opening comment block add the following code:

	
		var requestPath = HttpContext.Current.Request.Path.ToLower();
		// Bypass CMS for specific paths like .well-known
		if (requestPath.StartsWith("/.well-known")) {
			return;// Let IIS handle the request directly
		}
	

Update web.config

before the closing </system.webServer> tag (note if there is already a <rewrite><rules> block only add the <rule></rule> block):  NOTE: If the site has an https redirect add the new rule before the https redirect as this can cause issues with the verification.

View Code (opens in a new tab)