This morning I was putting a simple little web app online in our production system when bizarre things went wrong. I asked around and noone told me the right answer so I thought I’d blog it.
My simple little ASP.NET 2.0 web app takes an XML string from an HTTP POST, parses out the data elements, and persists it to the database. Nothing fancy. Works beautifully in the Visual Studio development IDE using the Cassini web server. However, when I copied the web files out to a folder underneath a running ASP (classic) application I started to get errors.
The first error I got was that there was an XML parsing error in my web.config on the <ConfigurationStrings> section. I’d clearly forgotten to change this web app to use the .Net 2.0 framework. A quick settings change and IISReset later, I went back to my site.
Instead of seeing my simple page, I was looking at a “Type not defined” error. Now, I only had 1 non-web form class in my project, and it was definitely present on the server in the App_Code directory. Everything worked on my machine inside of the IDE; this just didn’t make sense.
My first thought was that I copied the files out to the server wrong, so I used the built in Publish Web Site function to compile and copy the correct files out to the server. Hitting the page in IE again gave me this error:
Parser Error
Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately.
Parser Error Message: Could not load the assembly 'App_Web_default.aspx.cdcab7d2'. Make sure that it is compiled before accessing the page.
Source Error:
Line 1: <%@ page language="VB" autoeventwireup="false" inherits="_Default, App_Web_default.aspx.cdcab7d2" %>
Line 2:
Line 3: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
Really odd! I searched around in the ASP.Net forums and found the first bit of general advice to be to run “aspnet_regiis.exe -i” using the correct framework version of aspnet_regiis. I tried this but that didn’t help.
Ok – I took it back to my machine and tried to figure it out. Maybe the problem was also happening on my machine and since I’d only tested with Cassini, maybe I’d missed it. So I set up an IIS virtual directory, point it to my C:\Documents and Settings\MattR.MUSIC\My Documents\Visual Studio 2005\WebSites\MyApp folder and fire up IE. Strange error #3 – the ASPNET user doesn’t have permissions to the Assembly folder. Not believing that, I double-checked using SysInternal’s AccessEnum. I don’t find any problems with AccessEnum, so I start following the directions in Microsoft KB article 811320. It turns out that on my machine, the ASPNET user didn’t have permissions to my Application directory b/c the default for Visual Studio was to store the web site in my permissions restricted My Documents folder. I moved the app out to my local inetpub directory, fixed the IIS configuration, and tried again. PRESTO – it worked on my machine. Still with no code changes and so far no idea why it isn’t working on my web server.
Still looking around, I finally found the answer in the ASP.Net forums and on Experts Exchange – the MyApp directory on my web server was not marked as an application in IIS. This meant that when it hit my code, it went to the wrong App_Code folder looking for the missing type. Yet another quick change to my IIS configuration and the app started working swimmingly.
I’d like to point out that although there were error messages, they were not very helpful in finding the solution. I’d also like to thank Brendon and Chris Wallace for their suggestions.