Lincoln Bergeson
Lincoln Bergeson

Reputation: 3451

Why is my ASP.NET Application only showing a directory listing when I try to run it?

I opened Visual Studio 2012 Express for Web on my Windows 7 machine. I created an ASP.NET Empty Web Application named "EduPortal". I added a Web User Control to the project. In this User Control I put a button and a textbox and a button in a form. This is the code I used:

<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="WebUserControl1.ascx.cs" Inherits="EduPortal.WebUserControl1" %>

<form runat="server">
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<br />
<asp:Button ID="Button1" runat="server" Text="Button" />
</form>

I then built and ran the program. I got an error page from IIS Express, which instructed me to run these two commands on a command prompt in the IIS Express Install Directory:

appcmd set config /section:system.webServer/directoryBrowse /enabled:true
appcmd set config ["SITE_NAME"] /section:system.webServer/directoryBrowse /enabled:true

The first command ran without error. The second command, however, gave this message:

ERROR ( message:Cannot find SITE object with identifier "[SITE_NAME]". )

Anyway, I ignored the error. I rebuilt my project in Visual Studio. Now when I run the project I get this page:

enter image description here

Why is this happening, and what steps can I take to fix it?

Upvotes: 0

Views: 5011

Answers (1)

Cam Bruce
Cam Bruce

Reputation: 5689

You don't have any pages in your application, so IIS is showing the first available item, which is the directory listing, since there are no pages. You'll need at an ASPX (WebForm) or HTML (straight html) in your project. ASCX files are user controls, they are components of an ASPX (WebForm) page and they can't be loaded directly through the browser.

Upvotes: 3

Related Questions