그래서 프로젝트의 크기가 작고 물건을 가늘게 유지하려는 일반 의도로 인해 마스터 페이지를 사용하지 않습니다. 같은 간단한 cs 파일에 클래스를 포함하고 같은 페이지에서 사용하고 싶습니다.C# 클래스 상속 문제
// <copyright file="anon.cs" company="Anonymous">
// ;
// </copyright>
namespace cheese.pies.org
{
using System;
using System.IO;
using System.Net;
using System.Web;
using System.Xml;
/// <summary>
/// Class to process CAS authentication.
/// Based on solutions from CASE and Yale.
/// </summary>
public class CasLogin
{
/// <summary>
/// Address of university cas host
/// </summary>
private const string CasHost = "notimportant";
/// <summary>
/// Get the logged-in user's id or redirect them to login.
/// </summary>
/// <returns>
/// DirectoryID of logged in user
/// </returns>
public static string GetId()
{
...
}
...
}
나머지는 상당히 중요하지 않습니다. 나는 이것이 기본적인 구문 오류라고 생각한다.
다음은 페이지 포함을 사용하는 test.aspx 파일입니다.
<% @Page Language="C#" Inherits="CasLogin" CodeFile="anon.cs" %>
<script language="C#" runat="server">
protected void Page_Load(object sender, EventArgs e) {
String directoryId = CasLogin.GetId();
FormsAuthentication.RedirectFromLoginPage(directoryId, false);
}
</script>
내가 갖는 오류 :
Compiler Error Message: ASPNET: Make sure that the class defined in this code file matches the 'inherits' attribute, and that it extends the correct base class (e.g. Page or UserControl).
나는 이런 종류의에서 비교적 새로운 그리고 난 잘못 가고 무엇이 올바른 구문은 무엇을 알고 싶습니다. 감사!
형식 이름을 완전히 정규화하고 다시 시도 할 수 있습니까? 예 :'cheese.pies.org.CasLogin.GetId' - import 지시어가 필요할 것 같은데. – Tejs
오류가 사용자에게 말하려고합니다. – NSGaga
익명으로 작업하는 경우이 문제를 직접 해결할 수 있다고 생각합니다. – MarioDS