Saturday, January 7, 2017

Convert to Web Application: "The name 'objectName' does not exist in the current context"

If you're updating an old project into a web application, select the solution in the Solution Explorer, and then select to Project -> Convert to Web Application in the top menu:

This will create .aspx.designer.cs files in your project.   But you may run into the following error next:

   "The name 'objectName' does not exist in the current context"

If so check that you have the namespace declared around your class in the .aspx.designer.cs file, the Convert to Web Application action doesn't always add it:

namespace My.Namespace

    public partial class Default


You may also need to update the Page Directive's Inherit attribute to include the namespace:

<%@ Page ... Inherits="Default" %>


<%@ Page ... Inherits="My.Namespace.Default" %>

1 comment:

Tony Romo said...

Keep websiteing stuff like this I actually am fond of it.