Skip to content

Instantly share code, notes, and snippets.

@codingoutloud
Created October 3, 2012 19:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save codingoutloud/3829053 to your computer and use it in GitHub Desktop.
Save codingoutloud/3829053 to your computer and use it in GitHub Desktop.
Windows Azure Web About Box snippet
<!--
The beginnings of some useful context to display so one might understand some simple things about a
Windows Azure deployment without a lot of effort
Source: https://gist.github.com/3829053
-->
<!--
As might be included in an About page:
Note: only useful when run within a custom assembly; if run from within default.cshtml on, say, trivial
Windows Azure Web Sites site, it would show the About info for mscorlib, such as:
Last compiled: Saturday, January 21, 2012 at 5:40:04 PM UTC, File version: 4.0.0.0)
-->
<!--
TODO: add System uptime (e.g., http://stackoverflow.com/questions/972105/retrieve-system-uptime-using-c-sharp
or msdn.microsoft.com/en-us/library/system.environment.tickcount.aspx)
add ASP.NET uptime (e.g., http://www.codeproject.com/Articles/3311/Detecting-the-UpTime-of-Web-Server)
TODO: add ability to identity info about local resources (e.g.,
var logPath = RoleEnvironment.GetLocalResource("AdStreamerServiceLogs").RootPath;
ViewData["LogPath"] = logPath;
var partialDiagSetting = RoleEnvironment.GetConfigurationSettingValue(
"Microsoft.WindowsAzure.Plugins.Diagnostics.ConnectionString");
partialDiagSetting = partialDiagSetting.Substring(0,
Math.Max("UseDevelopmentStorage=true".Length, partialDiagSetting.Length / 2));
ViewBag.diagSetting = partialDiagSetting;
---
@Html.TextBox("Log File Path", ViewData["LogPath"])
<p>At the tone the local server time will be:</p>
<p>@DateTime.Now.ToLongTimeString()</p>
<p>Diagnostics Setting:</p>
<p>@ViewBag.diagSetting</p>
-->
<article>
@{
string assemblyName = String.Empty;
string assemblyCompiledUtc = String.Empty;
string assemblyVersion = String.Empty;
string exceptionInfo = String.Empty;
try
{
assemblyName = System.Web.Compilation.BuildManager.GetGlobalAsaxType().BaseType.Assembly.GetName().Name;
var assemblyCreatedUtc = new FileInfo(System.Web.Compilation.BuildManager.GetGlobalAsaxType().BaseType.Assembly.Location).CreationTimeUtc;
assemblyCompiledUtc = String.Format("{0} at {1} UTC", assemblyCreatedUtc.ToLongDateString(), assemblyCreatedUtc.ToLongTimeString());
assemblyVersion = System.Web.Compilation.BuildManager.GetGlobalAsaxType().BaseType.Assembly.GetName(false).Version.ToString();
}
catch (Exception ex)
{
exceptionInfo = ex.Message; // TODO: does razor not allow this to be called?
}
}
<ul>
<li><small>Assembly name: @assemblyName</small></li>
<li><small>Last compiled: @assemblyCompiledUtc</small></li>
<li><small>File version: @assemblyVersion</small></li>
</ul>
<small>@exceptionInfo</small>
</article>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment