上载到WebServer后出错

时间:2014-12-30 23:05:45

标签: asp.net hosting

我收到错误

Parser Error Message: Could not load type 'WebApplication2.WebForm2'.

当我在本地运行它时,项目工作正常,但是一旦我将其上传到托管服务器,我就会收到此错误。主机服务器运行.net 4.0,我正在使用目标平台.net 4.0构建,但我仍然收到此错误。

Default.aspx.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace WebApplication2
{
    public partial class WebForm2 : System.Web.UI.Page
    {
        bool loginSuccess = false;
        protected void Page_Load(object sender, EventArgs e)
        {
            if(IsPostBack)
            {
                Classes.Login login = Classes.Connection.TryLogin(Request.Form["Username"], Request.Form["Password"]);

                if (login != null)
                {

                    Session["Id"] = login.id;
                    Session["name"] = login.Firstname + " " + login.Lastname;
                    loginSuccess = true;
                    if (Classes.Connection.IsAdmin(login.id))
                        Session["admin"] = true;
                    else
                        Session["admin"] = false;

                   // ClientScript.RegisterStartupScript(this.GetType(), "myalert", "alert('You are an admin: " + Session["admin"] + "');", true);
                }
                else
                {
                    loginSuccess = false;

                }

                Label2.Visible = !loginSuccess;

            }

           if (Session["Id"] != null && Session["eventid"] == null)
            {
                Response.Redirect("events.aspx");
                //Session["Id"] = 1;
            }
            else if (Session["Id"] != null && Session["eventid"] != null)
            {
                Response.Redirect("admin.aspx");
            }

        }

        protected void Button1_Click(object sender, EventArgs e)
       {
            //ClientScript.RegisterStartupScript(this.GetType(), "myalert", "alert('Fake Login');", true);
           //Session Data
            /*if(Session["Id"] == null)
            {
                Response.Redirect("admin.aspx");
                Session["Id"] = 1;
            }*/


        }

        public void LoginCheck()
        {
            //ClientScript.RegisterStartupScript(this.GetType(), "myalert", "alert('Posted');", true);

        }

    }
}

的Default.aspx

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="WebApplication2.WebForm2" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Home Page</title>
</head>
<body style="background-color:beige;">
    <asp:Label ID="Label2" runat="server" ForeColor="Red" Text="Login Failed" Visible="false">     </asp:Label>
    <form id="form1" runat="server" action="Default.aspx" method="post">
        <asp:Label ID="Label1" runat="server" Text="Please Enter Your Login"></asp:Label>
        <br />
        Username:<asp:TextBox ID="Username" runat="server" TabIndex="1" Width="128px"></asp:TextBox>
         <br />
        Password: <asp:TextBox ID="Password" runat="server" TabIndex="2" TextMode="Password" Width="128px"></asp:TextBox>
        <br />
        <asp:Button ID="Button1" runat="server" OnClick="Button1_Click" TabIndex="3" Text="Login" />
    </form>

</body>
</html>

0 个答案:

没有答案