ASP.NET和C#的常规错误

Pat*_*k O 0 c# asp.net visual-studio-2013

我是stackoverflow的新手,需要帮助.

昨晚我在使用C#的ASP.NET网页上工作[我都是新手]并且在闪存驱动器发生故障后失去了很多进度后,我不得不从存储在谷歌驱动器上的备份中重写.把它放到我的电脑上后,我的一个网页出现了问题.起初它没有识别"当前上下文中存在的"对象,但是我重写了手写的页面,因为我认为这是由于复制粘贴事情造成的一些麻烦.现在我收到这些错误:

  1. 确保此代码文件中定义的类与'inherits'属性匹配,并且它扩展了正确的基类(例如Page或UserControl).
  2. 'ASP.index_aspx.GetTypeHashCode();:找不到合适的方法来覆盖
  3. 'ASP.index_aspx.ProcessRequest(System.Web.HttpContext)':找不到合适的方法来覆盖
  4. 'ASP.index_aspx'没有实现接口成员'System.Web.IHttpHandler.IsReusable'

使用我丢失的版本时,我根本没有遇到这些问题.这是我的代码:

这是我的"upload.aspx"页面

 <%@ Page Language="C#" AutoEventWireup="true" CodeFile="upload.aspx.cs" Inherits="upload" %>

 <!DOCTYPE html>

 <html xmlns="http://www.w3.org/1999/xhtml">
 <head runat="server">
     <title>BSHUpload</title>
 <link rel="stylesheet" href="http://yui.yahooapis.com/pure/0.5.0/pure-min.css"/>
 </head>
 <body>
 <!-- Menu -->
 <div class="pure-menu pure-menu-open pure-menu-horizontal">
    <ul>
        <li><a href="#">Home</a></li>
        <li class="pure-menu-selected"><a href="#">Upload</a></li>
        <li><a href="requests.aspx">Requests</a></li>
    </ul>
 </div>
<!-- Server-side Upload -->
    <form id="form1" runat="server" style="padding-left: 2em">
    <div>
    <h1>Upload a File</h1>
    </div>
    <div>
        <asp:Label ID="lblStatus1" runat="server" Text="---"></asp:Label>
        <asp:FileUpload ID="fdFileDrop1" runat="server" />
        <asp:Button ID="btnFileDrop1" runat="server" Text="upload" OnClick="btnFileDrop1_Click" />
    </div>
    </form>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)

我的代码背后:

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

public partial class upload : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void btnFileDrop1_Click(object sender, EventArgs e)
    {
        string strSavePath1 = "C:\\UploadBin\\";

    if (fdFileDrop1.HasFile)
    {

        string strFileName = fdFileDrop1.FileName;

            strSavePath1 += strFileName;
            fdFileDrop1.SaveAs(strSavePath1);

            lblStatus1.Text = "Your file was saved as " + strFileName;

    }
    else
    {
        lblStatus1.Text = "You did not specify a file to upload";
    }
}
 }
Run Code Online (Sandbox Code Playgroud)

因为我认为底部的3个错误是针对"index.aspx"页面,这里也是:

码:

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="upload.aspx.cs" Inherits="index" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>BSHUpload</title>
<link rel="stylesheet" href="http://yui.yahooapis.com/pure/0.5.0/pure-min.css"/>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.js"></script>
</head>
<body style="height: 228px">
<!-- Menu -->
    <div class="pure-menu pure-menu-open pure-menu-horizontal">
    <ul>
        <li><a href="#">Home</a></li>
        <li class="pure-menu-selected"><a href="upload.aspx">Upload</a></li>
        <li><a href="requests.aspx">Requests</a></li>
    </ul>
    </div>

    <form id="form1" runat="server" style="padding-left: 2em">

    </form>
<div>
    <button id="button1">Testing</button>
        <p id="toggle1">
        Wala
        </p>
    <script>
        $( "#button1" ).click(function() {
            $( "#toggle1" ).slideToggle( "slow" );
        })
    </script>
</div>
</body>
    </html>
Run Code Online (Sandbox Code Playgroud)

index.aspx的代码隐藏:

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

public partial class index: System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
}
Run Code Online (Sandbox Code Playgroud)

我真的希望你们能帮忙,因为我在这里难过.我很确定继承和"System.Web.UI.Page"都是正确的,但事实并非如此.

Cla*_*edi 6

问题出在了index.aspx.在文件的最顶部检查这一点

CodeFile="upload.aspx.cs" Inherits="index"
Run Code Online (Sandbox Code Playgroud)

那是错的.您指向错误的代码文件.它应该是

CodeFile="index.aspx.cs" Inherits="index"
Run Code Online (Sandbox Code Playgroud)