Category: Web Development


Recently I joined a new website hosting provider who supported WebMatrix and MVC. After I used Web Deploy to upload my working files to the server, I got 404 errors on some of the pages. After some investigation I realized that I had to specify the full cshtml file extension on all links. After doing some research, Rick Strahl once again saved my life. In his blog entry, he explained that the following line of code must be added to web.config, if hosted on IIS 7, for routing to work.

<modules runAllManagedModulesForAllRequests="true">

Who would have thought of that?

The following example demonstrates how to disable anonymous authentication in IIS, and enable windows authentication.


using (ServerManager serverManager = new ServerManager())
{
Microsoft.Web.Administration.Configuration config = serverManager.GetApplicationHostConfiguration();
Microsoft.Web.Administration.ConfigurationSection anonymousAuthenticationSection = config.GetSection
("system.webServer/security/authentication/anonymousAuthentication", webSiteName + "/" + applicationName);
anonymousAuthenticationSection["enabled"] = false;
Microsoft.Web.Administration.ConfigurationSection windowsAuthenticationSection = config.GetSection
("system.webServer/security/authentication/windowsAuthentication", webSiteName + "/" + applicationName);
windowsAuthenticationSection["enabled"] = true;
serverManager.CommitChanges();
}

If you get this message during compilation, right click on the solution and select Configuration Manager. For the build configuration you have selected, check the box of the project that compiler complained about.

I had a data string that used “<w>” as the delimiter passed into a javascript function from an event handler in HTML, and that was totally legal in .NET Framework 3.5. However, .NET Framework 4.0 detected that as a potentially dangerous value. By changing the delimiter to a string without the angle brackets, I stopped getting the run-time error. I thought that was a good improvement made in .NET 4.0.