TeaDrinkingGeek
TeaDrinkingGeek

Reputation: 2023

How do I get default.aspx working

My ISP needs a default.aspx page for my website. They said rename the index.aspx.

Problem is default is a keyword. If I rename index to default in index.aspx.cs file is gives the default keyword error:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace china
{
    public partial class default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }
    }
}

How to get around it. Any idea.

Regards Tea

Upvotes: 1

Views: 148

Answers (1)

Habib
Habib

Reputation: 223402

One other way would be rename your file with Default.aspx, Uppercase D, this will remove the error since Default in C# is different to default (case senstive) and would work for the file system as well. (since file system on Windows would be case insenstive)

Otherwise rename only the file name, not the class name in the code. One way to do that would be to rename on File Explorer, but remember to correctly specify the file name in CodeBehind attribute in ASPX page.

Upvotes: 5

Related Questions