Disguises the aspx page as static html implementation code

  • 2020-05-16 06:39:38
  • OfStack

Add the Application_BeginRequest event to Global.asax:
 
protected void Application_BeginRequest(object sender, EventArgs e) 
{ 
string pathAndQuery = Request.Url.PathAndQuery.ToLower(); 
if (pathAndQuery.IndexOf(".html") > -1) 
{ 
pathAndQuery = "~/" + pathAndQuery.Replace(".html", ".aspx"); 
HttpContext.Current.RewritePath(pathAndQuery); 
} 
} 

This allows you to access your xxx.aspx page using xxx.html, and the browser's address bar displays xxx.html (you can also take parameters with the page).

Related articles: