Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Programmieren allgemein (https://www.delphipraxis.net/40-programmieren-allgemein/)
-   -   ASP.NET: Error message: Cannot find type _Default (https://www.delphipraxis.net/77071-asp-net-error-message-cannot-find-type-_default.html)

Pseudemys Nelsoni 14. Sep 2006 11:03


ASP.NET: Error message: Cannot find type _Default
 
Hallo,

ich habe folgende "quotes.aspx" Datei:

XML-Code:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="quotes.aspx.cs" Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Unbenannte Seite</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
       <%= jo() %>
    </div>
    </form>
</body>
</html>

und diese "quotes.aspx.cs":

Code:
using System;
using System.Configuration;
using MySql.Data.MySqlClient;

partial class _Default : System.Web.UI.Page
{
    static protected void Main()
    {

    }

    protected string jo()
    {
        MySqlConnection conn = new MySqlConnection();
        conn.ConnectionString = @"Server=stdcall.de;Database=nightirc;Uid=silent;Pwd=5366;";
        MySqlCommand cmd = new MySqlCommand(@"SELECT * FROM quotes;", conn);
        MySqlDataReader dr;
        string res = String.Empty;

        conn.Open();

        dr = cmd.ExecuteReader();

        while (dr.Read())
        {
            res += dr.GetString(2) + "
";
        }

        conn.Close();

        return res;
    }

    protected void Page_Load(object sender, EventArgs e)
    {

    }
Wenn ich nun auf www.nightirc.de/quotes.aspx gehe, meint die Seite:

Zitat:

Error message: Cannot find type _Default

File name: /home/nightirc/quotes.aspx Line: 1

Woher kommt denn der Fehler? Die Klasse in quotes.aspx.cs heisst doch "_Default" oder nicht?

Elvis 14. Sep 2006 12:01

Re: ASP.NET: Error message: Cannot find type _Default
 
Kann ich nicht ganz nachvollziehen. (Soll heißen: bei mir gates) Aber bennenne doch einfach die Seite so wie die ASPX? :gruebel:
Du hast auch den mySQL Provider in dem Ordner liegen? Sonst könnte er _Default nicht kompilieren und dann könnte ASPX ja nicht davon ableiten....

Was den Code angeht, rate mal wofür es using gibt und rate mal warum die ganzen Datenbank-Kraduntsches IDisposable implementieren? :roll:

Code:
using (IDbConnection connection = new MySqlConnection())
using (IDbCommand command = connection.CreateCommand())
{
  connection.ConnectionString = "Server=stdcall.de;Database=nightirc;Uid=silent;Pwd=5366;";
  command.CommandText        = "SELECT * FROM quotes";

  string res = String.Empty;

  conn.Open();

  using (IDataReader reader = command.ExecuteReader())
  {
    while(reader.Read())
    {
      res += reader.GetString(2) + "
";
    }
  }
  return res;
}

Pseudemys Nelsoni 14. Sep 2006 12:31

Re: ASP.NET: Error message: Cannot find type _Default
 
Die Sache ist die: Unter Windows funktioniert es mit dem ISS, unter Linux (SuSE 10.0) mit Mono/mod_mono und Apache nicht.

@using: Das wusste ich nicht, gleich mal abändern <g>.

Dennoch wird die Seite aber nicht funktionieren :?


Alle Zeitangaben in WEZ +1. Es ist jetzt 09:08 Uhr.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz