Help with Build Your Own ASP.Net 4 Website Using C#, 4th Edition

I am on Chapt. 3, Arrays. My results are not showing up in the browser and I get the below error. I have tried creating a default.aspx page in my project and that made it stop throwing the error, but the results still do not show up in the browser. Here is my code, the books code actually, when mine didn’t work, I tried theirs. It still doesn’t work.

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="arrays.aspx.cs" Inherits="arrays222.arrays" %>

<!DOCTYPE html>

<script runat="server">
  void Page_Load()
  {
    // Declare an array
    string[] drinkList = new string[4];
    // Place some items in it
    drinkList[0] = "Water";
    drinkList[1] = "Juice";
    drinkList[2] = "Soda";
    drinkList[3] = "Milk";
    // Access an item in the array by its position
    drinkLabel.Text = drinkList[0];
  }
</script>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Arrays</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
      <asp:Label ID="drinkLabel" runat="server" />
    </div>
    </form>
</body>
</html>

Error

"HTTP Error 403.14 - Forbidden
The Web server is configured to not list the contents of this directory.
Most likely causes:
• A default document is not configured for the requested URL, and directory browsing is not enabled on the server.
Things you can try:
• If you do not want to enable directory browsing, ensure that a default document is configured and that the file exists.
• Enable directory browsing.

  1. Go to the IIS Express install directory.
  2. Run appcmd set config /section:system.webServer/directoryBrowse /enabled:true to enable directory browsing at the server level.
  3. Run appcmd set config [“SITE_NAME”] /section:system.webServer/directoryBrowse /enabled:true to enable directory browsing at the site level.
    • Verify that the configuration/system.webServer/directoryBrowse@enabled attribute is set to true in the site or application configuration file.
    Detailed Error Information:
    Module DirectoryListingModule
    Notification ExecuteRequestHandler
    Handler StaticFile
    Error Code 0x00000000
    Requested URL http://localhost:49637/
    Physical Path c:\users\steve\documents\visual studio 2012\Projects\arrays222\arrays222
    Logon Method Anonymous
    Logon User Anonymous
    Request Tracing Directory C:\Users\Steve\Documents\IISExpress\TraceLogFiles\ARRAYS222
    More Information:
    This error occurs when a document is not specified in the URL, no default document is specified for the Web site or application, and directory listing is not enabled for the Web site or application. This setting may be disabled on purpose to secure the contents of the server.
    View more information »"

This is a fairly generic error. The first thing I’d check is if the directory has permissions to serve the document.

If that does not work, then try just a plain ole html page. If that works then add code.