My ASP.NET code couldn't run .aspx.cs code

Discussion in 'ASP.NET / ASP.NET Core' started by yuyang, Feb 26, 2004.

Thread Status:
Threads that have been inactive for 5 years or longer are closed to further replies. Please start a new thread.
  1. I can use the connection string to connect the database on my computer, but when I upload my code to discount.net webhoster. It doesn't work. I thought maybe the problem is:

    when I run my code in my computer, the first line of my HTML code is:

    <%@ Page language="c#" Codebehind="science.aspx.cs" AutoEventWireup="false" Inherits="OnlineBook.secience" %>

    This line will let my .aspx.cs code (C# code) work to connect the database. But when I upload my code to your webhoster, I should delete this line, otherwise the error information like below:

    Server Error in '/' Application. Runtime Error Description: An application error occurred on the server. The current custom error settings for this application prevent the details of the application error from being viewed remotely (for security reasons). It could, however, be viewed by browsers running on the local server machine.


    How can I correct my first line HTML code? or should I correct some code in web.config?
     
  2. Bruce

    Bruce DiscountASP.NET Staff

    1) You should not delete that line or else your page would not know how to load the code behind

    2) Do what the error say. ie. change your web.config file to show the real error.

    Update the CustomError line, set it to Off


    quote:Originally posted by yuyang

    I can use the connection string to connect the database on my computer, but when I upload my code to discount.net webhoster. It doesn't work. I thought maybe the problem is:

    when I run my code in my computer, the first line of my HTML code is:

    <%@ Page language="c#" Codebehind="science.aspx.cs" AutoEventWireup="false" Inherits="OnlineBook.secience" %>

    This line will let my .aspx.cs code (C# code) work to connect the database. But when I upload my code to your webhoster, I should delete this line, otherwise the error information like below:

    Server Error in '/' Application. Runtime Error Description: An application error occurred on the server. The current custom error settings for this application prevent the details of the application error from being viewed remotely (for security reasons). It could, however, be viewed by browsers running on the local server machine.


    How can I correct my first line HTML code? or should I correct some code in web.config?


    </blockquote id="quote"></font id="quote">
     
  3. Bruce

    Bruce DiscountASP.NET Staff

    Do you have a dll named OnlineBook.dll in your bin directory?

    This error indicate that the page is trying to load this assembly

    quote:Originally posted by yuyang

    At first, thanks for your help.

    I had followed your advice to do. I keep the first line of HTML codes and set the customErrors to be off in web.config. There is still a error of my website. The error show below:

    Server Error in '/' Application.
    ---------------------------------------------------------------------

    Parser Error
    Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately.

    Parser Error Message: Could not load type 'OnlineBook.main1'.

    Source Error:


    Line 1: <%@ Page language="c#" Codebehind="main1.aspx.cs" AutoEventWireup="false" Inherits="OnlineBook.main1" %>
    Line 2: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"-->
    Line 3: <HTML>


    Source File: E:\web\bookhillcom\htdocs\main1.aspx Line: 1

    Should I create a project named "OnlineBook" in my FTP host? Cause OnlineBook is my project in my computer. [:I][?]


    </blockquote id="quote"></font id="quote">
     
  4. Okay... You should take a little time and read about how a web application is deployed in .NET, there are some good walkthroughs in the Visual Studio help, and if you don't have help, search MSDNmsdn.microsoft.com. When you use code-behind, a .DLL file is created which contains the compiled version of your .CS code. Your asp.net application will expect to find this .DLL in a directory called /bin off the root of your website. Find that on your computer and FTP it to the same directory (/bin) on your website. Everything should work as it does on your computer.

    quote:Originally posted by yuyang

    At first, thanks for your help.

    I had followed your advice to do. I keep the first line of HTML codes and set the customErrors to be off in web.config. There is still a error of my website. The error show below:

    Server Error in '/' Application.
    ---------------------------------------------------------------------

    Parser Error
    Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately.

    Parser Error Message: Could not load type 'OnlineBook.main1'.

    Source Error:


    Line 1: <%@ Page language="c#" Codebehind="main1.aspx.cs" AutoEventWireup="false" Inherits="OnlineBook.main1" %>
    Line 2: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"-->
    Line 3: <HTML>


    Source File: E:\web\bookhillcom\htdocs\main1.aspx Line: 1

    Should I create a project named "OnlineBook" in my FTP host? Cause OnlineBook is my project in my computer. [:I][?]


    </blockquote id="quote"></font id="quote">
     
  5. At first, thanks for your help.

    I had followed your advice to do. I keep the first line of HTML codes and set the customErrors to be off in web.config. There is still a error of my website. The error show below:

    Server Error in '/' Application.
    ---------------------------------------------------------------------

    Parser Error
    Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately.

    Parser Error Message: Could not load type 'OnlineBook.main1'.

    Source Error:


    Line 1: <%@ Page language="c#" Codebehind="main1.aspx.cs" AutoEventWireup="false" Inherits="OnlineBook.main1" %>
    Line 2: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"-->
    Line 3: <HTML>


    Source File: E:\web\bookhillcom\htdocs\main1.aspx Line: 1

    Should I create a project named "OnlineBook" in my FTP host? Cause OnlineBook is my project in my computer. [:I][?]
     
  6. Guys, Thanks a lot! My code is working now. I just copied my OnlineBook.dll file from my computer to my bin file in FTP. All problem had solved. Thanks again![:D][:)]
     
Thread Status:
Threads that have been inactive for 5 years or longer are closed to further replies. Please start a new thread.

Share This Page