2012-05-01 4 views
0

그래서 프로젝트의 크기가 작고 물건을 가늘게 유지하려는 일반 의도로 인해 마스터 페이지를 사용하지 않습니다. 같은 간단한 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). 

나는 이런 종류의에서 비교적 새로운 그리고 난 잘못 가고 무엇이 올바른 구문은 무엇을 알고 싶습니다. 감사!

+1

형식 이름을 완전히 정규화하고 다시 시도 할 수 있습니까? 예 :'cheese.pies.org.CasLogin.GetId' - import 지시어가 필요할 것 같은데. – Tejs

+2

오류가 사용자에게 말하려고합니다. – NSGaga

+0

익명으로 작업하는 경우이 문제를 직접 해결할 수 있다고 생각합니다. – MarioDS

답변

0

귀하의 오류 메시지가 당신에게 문제를 알려줍니다. 여기에 클래스를 변경합니다 : 그것은 당신을 말하고

public class CasLogin : Page 
+0

이 문제는 해결되었지만 다른 문제가 발생했습니다. 나는 또 하나를 올릴거야 ... –

4

그냥 페이지에서 파생 클래스를 업데이트

public class CasLogin : Page 
{ 
0

정확히 어떤 문제가 :

컴파일러 오류 메시지 : ASPNET : 확인이 코드 파일에 정의 된 클래스는 '상속'속성과 일치하는지 확인, 및 올바른 기본 클래스 (예 : Page 또는 UserControl)를 확장합니다.

public class CasLogin {}Page 또는 UserControl을 확장 하시겠습니까?