Again, I’m fairly new at this sort of thing and perhaps the error message is telling me what it is and I’m simply not understanding, but… This code in anon.cs
namespace cheese.pies.org
{
using System;
using System.IO;
using System.Net;
using System.Web;
using System.Xml;
public class CasLogin : System.Web.UI.Page
{
private const string CasHost = "notimportant";
public static string GetId()
{
}
}
Ends up giving me an error when referenced here:
<% @Page Language="C#" Inherits="CasLogin" CodeFile="CasLogin.cs" %>
<script language="C#" runat="server">
protected void Page_Load(object sender, EventArgs e) {
String directoryId = CasLogin.GetId();
FormsAuthentication.RedirectFromLoginPage(directoryId, false);
}
</script>
The error is on line one and is:
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).
If I change it from
public class CasLogin : System.Web.UI.Page
to
public class CasLogin : Page
I get this error:
Compiler Error Message: CS0246: The type or namespace name ‘Page’ could not be found (are you missing a using directive or an assembly reference?)
You are missing the correct
usingstatement for thePageclass (System.Web.UI) thus when you remove the full qualification the compiler can no longer find thePageclass.You should also fully-qualify the class name in the Page directive, i.e.
Inherits="cheese.pies.org.CasLogin"Good
Bad
Per your comment regarding a missing
partialmodifier:Should be:
This tells the compiler that the
CasLoginclass is defined in multiple files (which is the case with web forms; the designer file is separate from the code behind file).If it still doesn’t work, I suggest recreating the page and copying any relevant code into it. Normally Visual Studio handles all of this automatically and this is a non-issue.