0121 31 45 374
Qoute Icon

Page name conflicts

Tim

I know a fair few people have come across the error which, having a page called “Login.aspx” causes the error message “CS0108: 'ASP.login_aspx.Profile' hides inherited member 'Login.Profile'. Use the new keyword if hiding was intended.” But I’ve found another when calling a page sitemap.aspx: “CS0108: 'ASP.sitemap_aspx.Profile' hides inherited member 'SiteMap.Profile'. Use the new keyword if hiding was intended.” So just be careful not to name your pages the same as the controls.

If like me however you like to keep some sort of consistency in the page names across your sites, you can easily get around it by renaming the page’s partial class name to something which doesn’t conflict and then updating the page’s codebehind reference i.e. for sitemap.aspx:

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

    }
}

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="sitemap.aspx.cs" Inherits="_pgSiteMap" Title="Site Map" %>

Liked this post? Got a suggestion? Leave a comment