Page name conflicts

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)     {    } }<%@PageLanguage="C#"AutoEventWireup="true"CodeFile="sitemap.aspx.cs"Inherits="_pgSiteMap"Title="Site Map"%>

Subscribe to TSD

Don’t miss out on the latest posts. Sign up now to get access to the library of members-only posts.
jamie@example.com
Subscribe