Error starting up a production web application in Visual Web Developer 2010 Express

I am compiling support for an old .NET web application that was developed in Visual Studio 2008. However, I am using Visual Web Developer 2010 Express. I downloaded the project code directly from the latest working version as a web application. Everything compiles and loads the settings for the target version of the .NET Framework 3.5.

However, when debugging, the first requested page results in a "Compilation Error" error with the message

"* CS1061:" ASP.site_master "does not contain a definition for" LinkButton2_Click ", and the extension method" LinkButton2_Click "cannot be found that accepts the first argument of type" ASP.site_master "(do you miss the using directive or the assembly reference?) * "

Here is the relevant code information:

From Site.Master:

  <%@ Master Language="C#" AutoEventWireup="true" CodeBehind="Site.Master.cs"  %>
   ...
   <asp:LoginView ID="LoginView1" runat="server" >
   <AnonymousTemplate>
      <asp:LinkButton ID="LinkButton2" runat="server" Click="LinkButton2_Click"> Login
      </asp:LinkButton>
   </AnonymousTemplate>

From Site.Master.cs:

 public partial class Site : BaseMasterPage  // BaseMasterPage is subclass of System.Web.UI.MasterPage
 ...
 public void LinkButton2_Click(object sender, EventArgs e)
    {
        Response.Redirect("/Login.aspx?ReturnURL="+ Request.Url.AbsolutePath);
    }

Obviously, the code is defined and there are no visible typos.

I am primarily a Java developer, but I have honest experience with .NET. However, this problem annoys me a lot, so I need help navigating it. I researched it extensively through Google, and this type of problem has been repeatedly reported, including here in the Stack Overflow section. But not one of the resolutions cited in previous reports helped solve this problem for me. This is extremely puzzling, because the code clearly works the way it currently works in production. This is a problem with Visual Studio 2008 and Visual Web Developer 2010 Express.

+4
1

Inherits = "Site" . codebehind.

Site.Master.aspx:

<%@ Master Language="C#" Inherits="<full namespace>.Site" CodeBehind="Site.Master.cs" AutoEventWireup="true" %>

Site.Master.cs

+2

Source: https://habr.com/ru/post/1526634/


All Articles