Posts

Showing posts with the label configuration management

ASP.NET: Change page title based on database to which you're connecting

On occasion, you may find it useful to provide a visual cue that the user is not in an application's production environment. This is especially useful during a late night crunch when the developers, system administrators, and the Q.A. team are distracted and tired. Below is some code which allows you to change the page title and its style based on the database specified in a connection string. Note that we are parsing an Entity Framework connection string, not an ADO.NET connection string. Site.Master <div class="navbar navbar-inverse navbar-fixed-top">     <div class="container">         <div class="navbar-header">             <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">                 <span class="icon-bar"></span>                 <span class="...

ASP.NET Routing Not Working in IIS

After deploying a brand new website to IIS on Windows Server 2008 R2, I encountered numerous issues. First, the web pages had no no styling. I could "View Source" and see that the code was correct, and I could browse to the folder containing the style sheets (bootstrap, my new obsession) and bring up the style sheet itself, but the application couldn't find the style sheets at run time on its own. Next, none of the links worked. The page "StudentsList", which should bring up "StudentsList.aspx" returned a HTTP 404 status. After futzing around a bit, it dawned on me that both issues stemmed from routing problems. In no time, I found several suggestions -- including good ol' Rick Strahl's blog -- most of which pointed to the same fix. Add the runAllManagedModulesForAllRequests attribute to the <modules> tag of the <system.WebServer> section of the web.config file. See Strahl's entry for more details: https://weblog.wes...