BuZz
BuZz

Reputation: 17445

ASP.NET : why is my website serving Default.asp instead of Default.aspx

my "hello world" ASP.NET application works fine in debug. However, after I publish, I have issues :

  1. where do I control whether I want my website to serve Default.aspx or .asp as default page ? When I debug, it is calling Default.aspx with no problems, but after publish, it seems to request Default.asp

  2. why do I get this error when I request Default.aspx manually ? (in browser)

    The XML page cannot be displayed Cannot view XML input using XSL style sheet. Please correct the error and then click the Refresh button, or try again later. A name was started with an invalid character. Error processing resource 'http://localhost/slidenet/default.aspx'. Line 1, ...

    <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="WebApplication1._Default" %> -^

  3. if I don't request a page, it will call my Default.asp that I created on purpose, and again, same error : The page cannot be displayed There is a problem with the page you are trying to reach and it cannot be displayed.


Please try the following:

Click the Refresh button, or try again later.

Open the localhost home page, and then look for links to the information you want. HTTP 500.100 - Internal Server Error - ASP error Internet Information Services


Technical Information (for support personnel)

Error Type: Active Server Pages, ASP 0221 (0x80004005) The specified 'Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="WebApplication1.Default" ' option is unknown or invalid. /slidenet/Default.asp, line 1

Browser Type: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 1.1.4322; .NET CLR 2.0.50727; InfoPath.2; .NET CLR 3.0.04506.30; .NET CLR 3.0.04506.648; .NET CLR 3.5.21022; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; .NET4.0C; .NET4.0E)

Page: GET /slidenet/Default.asp

Time: 11 January 2012, 14:00:02

More information: Microsoft Support

Upvotes: 2

Views: 2912

Answers (4)

Michiel van Oosterhout
Michiel van Oosterhout

Reputation: 23084

The order of default documents matters, documents at the top of the list of default document have priority over those lower on the list. See the screenshot below (IIS 7): Default.asp (if present) will be served by IIS, even if default.aspx is present. This is only because default.asp is higher in the list.

enter image description here

Use the Move Up option to make default.aspx the default over Default.asp.

On Windows XP with IIS 6:

enter image description here

If you want to do it in web.config, you can clear the defaultDocuments setting first, before adding default.aspx:

<defaultDocument>
  <files>
    <clear />
    <add value="Default.aspx" />
  </files>
</defaultDocument>

Or remove only default.asp:

<defaultDocument>
  <files>
    <remove value="default.asp" />
    <add value="default.aspx" />
  </files>
</defaultDocument>

Upvotes: 1

Crab Bucket
Crab Bucket

Reputation: 6277

Could be that aspx engine hasn't been registered correctly with IIS. The handlers for aspx are not present.

Try running aspnet_regiis -i (MSDN link) from the command line. It needs to be run from the directory of the version of the .Net framework you are installing i.e. C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727

I've seen this happen when IIS has been installed after the .Net framework so it doesn't have a chance to register

The default page is a setting in IIS for the website as explained in the other answers.

Upvotes: 2

stooicrealism
stooicrealism

Reputation: 558

add this code to your web.config

   <defaultDocument>
    <files>
      <add value="Default.aspx" />
    </files>
  </defaultDocument>

you can also check the default documents under IIS settings

Upvotes: -1

alcatraz
alcatraz

Reputation: 47

If you're running it using visual studio "virtual" webserver you must rightclick on default.aspx and select "set as start page" in the solution explorer tab. If you're running it in a IIS environement you must select the correct start page from the proprieties dialog-box in IIS. I would also suggest a clean rebuild of your project (Build-> Clean [projectname])

Upvotes: 0

Related Questions