<%@ Page language="c#" Inherits="System.Web.UI.Page"%>
<%@ Register TagPrefix="loc" Namespace="Microsoft.Crm.Application.Controls.Localization" Assembly="Microsoft.Crm.Application.Components.Application" %>

<!DOCTYPE html>
<html lang="en">
<head>
	<meta http-equiv="x-ua-compatible" content="IE=edge">
	<meta charset="utf-8" />
	<script type="text/javascript">var PageLoadStartTime = Date.now();</script>
	<title>Dynamics 365</title>
	<link rel="stylesheet" href="resources/styles/shim.css?v=<REPLACEWITHVERSIONINBUILD>" type="text/css" />
</head>
<body>
	<script language="c#" runat="server">
		public void Page_Load(object sender, EventArgs e)
		{
			var mailappMainPage = HttpContext.Current.Server.MapPath("/crmmailapp/index.html");
			string htmlContent = null;

			using (var reader = new System.IO.StreamReader(mailappMainPage))
			{
				htmlContent = reader.ReadToEnd();
			}

			if (!string.IsNullOrWhiteSpace(htmlContent))
			{
				bool useLocal = Request.QueryString["useLocal"] == null ? false : bool.Parse(Request.QueryString["useLocal"]);

				if (useLocal)
				{
					htmlContent = htmlContent.Replace("/crmmailapp/", "https://localfile.crm.dynamics.com/");
				}

				Response.Write(htmlContent);
			}
		}
	</script>
</body>
</html>