问题描述
操作环境与场景:
在 Windows 10 中 Visual Studio 2017 编写网页时,提示报错:
原因分析:
报错可能原因:
- 页面的aspx文件内第一行中CodeFile属性和Inherits属性指定到了其他页面
确保包含了正确版本的 .NET Framework。
确保您的项目中包含了正确版本的 .NET Core。
确保您的项目中包含了正确版本的 System.Security.Cryptography NuGet 包。
解决方案:
解决步骤:
- 首先检查了第一行的CodeFile属性和Inherits属性,发现都指定错了,指定得到了 publish.aspx 页面了。可能是我当时页面是直接复制粘贴的原因。
export.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="publish.aspx.cs" Inherits="TeacherManagementSystem_publish" %>
- 将上述中错误的属性重新指定为本页面的名称
export.aspx
CodeFile="export.aspx.cs" Inherits="TeacherManagementSystem_export"
附言:
CodeFile的值为本页面名称加.CS,Inherits的值为本页面的.CS文件中的公共类名称。
请记住不要再复制粘贴网页,这种情况通常都为复制粘贴网页造成。