C# asp.net无法从代码隐藏引用变量

C# asp.net无法从代码隐藏引用变量,c#,asp.net,C#,Asp.net,我已经在其他代码上完成了这项工作,并且运行良好,但由于某种原因,在VStudio 2017的一个新项目中,我无法从c#code behind中引用asp/html中的变量。然后,我使用about.aspx启动了一个新的测试空白asp web项目,同样的内容请参见下面的代码,我不知道为什么它不工作。当前上下文消息中不存在“teststring”,但它确实存在。我完全错过了什么 ASP/HTML <%@ Page Title="About" Language="C#" MasterPageFi

我已经在其他代码上完成了这项工作,并且运行良好,但由于某种原因,在VStudio 2017的一个新项目中,我无法从c#code behind中引用asp/html中的变量。然后,我使用about.aspx启动了一个新的测试空白asp web项目,同样的内容请参见下面的代码,我不知道为什么它不工作。当前上下文消息中不存在“teststring”,但它确实存在。我完全错过了什么

ASP/HTML
<%@ Page Title="About" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="About.aspx.cs" Inherits="TestApp.About" %>

<asp:Content ID="BodyContent" ContentPlaceHolderID="MainContent" runat="server">
    <h2><%: Title %>.</h2>
    <h3>Your application description page.</h3>
    <p>Use this area to provide additional information.</p>
    <%=teststring %>
</asp:Content>

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

namespace TestApp

{
    public partial class About : Page

    {
        public string teststring;

        protected void Page_Load(object sender, EventArgs e)

        {
            teststring = "test";
        }
    }
}
ASP/HTML
.
您的应用程序描述页面。
使用此区域可提供其他信息

# 使用制度; 使用System.Collections.Generic; 使用System.Linq; 使用System.Web; 使用System.Web.UI; 使用System.Web.UI.WebControl; 命名空间TestApp { 公共分部类关于:第页 { 公共字符串teststring; 受保护的无效页面加载(对象发送方、事件参数e) { teststring=“test”; } } }
在ASPX顶部的
标记处,将属性
Inherits=“TestApp.About”
的值更改为
Inherits=“TestApp\u About”
。下划线而不是点/句点。我能够复制这个问题。

它给您带来了什么确切的错误?它是不是在抱怨
teststring
?或者可能是
标题
?您是否构建了解决方案?如果您中断页面加载,它是否真的命中了它?您是否看到“使用此区域…”消息呈现到屏幕上?因此我将其更改为“并重建”和相同的内容,然后将其更改回。重建,现在它可以工作了。奇怪的