The name 'username' does not exist in the current context for web projects compiled in x64 RRS feed

  • Question

  • User151220215 posted

    I have an ASP.NET web application with the following in the aspx page

    <asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
            var username = "<%=username%>";


    The code behind sets up the variable username for example:

    public string username = "david";

    In Visual Studio error list pane, it shows this error "The name 'username' does not exist in the current context"

    So basically any page that I use <%=VARIABLE%> then I get this error.  But it compiles fine and works as expected.  But this error is really annoying when I have other pages with several of these errors.  This only happens when I build the project as x64.  It works fine if I change the project to x86, but my other project in same solution must be x64 and referenced by my web app so everything needs to be x64 or it complains.  So why is it that Visual Studio complains about this error incorrectly when it compiles just fine?  What can I do to fix this?  Is this a bug I need to report to Visual Studio team?

    Thursday, March 1, 2018 3:20 PM

All replies

  • User283571144 posted

    Hi eeldivad,

    According to your description, I have created a test demo on my side, it works well.

    I suggest you could send the feedback with your visual studio version by using visual studio.

    My IIS express is 64bit and compile mode is x64.


    Best Regards,


    Friday, March 2, 2018 2:46 AM