p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   VS.NET 2002/2003 (http://p2p.wrox.com/forumdisplay.php?f=103)
-   -   Uploading and Running vs.net on remote server (http://p2p.wrox.com/showthread.php?t=13481)

X-Ken May 27th, 2004 01:16 AM

Uploading and Running vs.net on remote server
 
Hi,

I had problem in running vs.net on remote server.
it says the error was with the inheritance,
<%@ Page Language="vb"
AutoEventWireup="false" Codebehind="src=Webform1.aspx.vb"
Inherits="something.Webform1" %>
I added the file directly under c:/inetpub/wwwroot/something/ which is located on remote server.
It seems that the file is not loaded into something's remote directory(localhost/something/) - (however it will be stored into the remote directory's automatically if i use 'add existing feature')

Please help


planoie May 27th, 2004 07:32 AM

This question is a little confusing but I think I know what the problem is.

You are trying to upload an ASP.NET page: Webform1.aspx
This page needs to inherit from the class "something.Webform1".
This class will live in your compiled DLL. If c:/inetpub/wwwroot/something/ is NOT configured as an application, then the class "something.Webform1" is assumed to live in an assembly that is located in c:/inetpub/wwwroot/bin. You can put the assembly in c:/inetpub/wwwroot/something/bin but it will not be found by the ASP.NET runtime unless c:/inetpub/wwwroot/something is an application.

When you create the directory for "something", you need to go into IIS and make that directory an application. To do this:
- Start IIS manager
- Navigate to the subdirectory "something" under the default web site
- Right-click, and choose properties
- On the directory tab, look for "Application Settings"
- Under that, you should find a "Create" button.
- Click "Create" button. This creates an application on that subdirectory.

Now when the aspx page is run, the .NET runtime will look for assemblies under something/bin.

Peter
-------------------------
Work smarter, not harder

X-Ken May 27th, 2004 10:33 AM

Hi there,

Thank you for the reply. I am sorry if I didn't say it clearly, the problem is I tried to create a webform that inherits Assg2, however instead of add it using 'add existing item.. ' tool (inside vs.net solution explorer), I copied it directly into c:/inetpub/wwwroot/Assg2 then I tried to access the page from internet explorer. But when I tried to get the page from internet explorer, the below error message occured.


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 'Assg2.WebForm1'.

Source Error:


Line 1: <%@ Page Language="vb" AutoEventWireup="false" Codebehind="WebForm1.aspx.vb" Inherits="Assg2.WebForm1"%>
Line 2: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
Line 3: <HTML>

Do you know why?

Thanks


planoie May 27th, 2004 10:40 AM

The server is telling you "Parser Error Message: Could not load type 'Assg2.WebForm1'."

This is because you are adding a page but that page's base class doesn't exist in the assembly of you application. You can't just add a page unless it's either completely self contained (relies on no assembly based classes) or it uses classes that already exist in assemblies that are in the application's /bin folder.

It sounds as though you are not entirely clear on how the asp.net runtime functions with compiled code-behind.

X-Ken May 27th, 2004 10:46 AM

Is there a way to overcome the problem? How to put the base class into the assembly?


planoie May 27th, 2004 10:49 AM

I don't see this as a "problem", it's the way things work. You need to compile the base class into an assembly. How you do that is up to you.

X-Ken May 27th, 2004 10:54 AM

Oh.. what if I don't have access to compile the base class?
For example I was given an ftp path by my web server to upload my class but he didn't say I have access to do compilation on his server, my class will just be simply uploaded to its server directory "c:/inetpub/www/Assg2".


planoie May 27th, 2004 11:21 AM

You shouldn't be compiling on the server. Compile locally, and upload the ASPX and the .DLL files.

X-Ken May 28th, 2004 02:47 AM

cool i copied all files which are in localhost to the server and finally the page can be displayed however the button is not working. for example i cannot do
buttonclick{byval sender as object, ....)
textbox1.text = "text"}

Why is that?


shahchi1 May 28th, 2004 08:46 AM

would you post your code

X-Ken May 28th, 2004 11:43 AM

I mean it seems it is not accessing the aspx.vb
I tried Response.write("test") as well
the code is:

<%@ Page Language="vb" AutoEventWireup="false" Codebehind="WebForm1.aspx.vb" Inherits="Assg2.WebForm1"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
    <HEAD>
        <title>WebForm1</title>
        <meta name="GENERATOR" content="Microsoft Visual Studio .NET 7.1">
        <meta name="CODE_LANGUAGE" content="Visual Basic .NET 7.1">
        <meta name="vs_defaultClientScript" content="JavaScript">
        <meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
    </HEAD>
    <body MS_POSITIONING="GridLayout">
        <form id="Form1" method="post" runat="server">
            <asp:TextBox id="TextBox1" style="Z-INDEX: 101; LEFT: 328px; POSITION: absolute; TOP: 120px"
                runat="server"></asp:TextBox>
            <asp:Button id="Button1" style="Z-INDEX: 102; LEFT: 320px; POSITION: absolute; TOP: 224px" runat="server"
                Text="Button"></asp:Button>
        </form>
    </body>
</HTML>


for aspx.vb:

Public Class WebForm1
    Inherits System.Web.UI.Page

#Region " Web Form Designer Generated Code "

    'This call is required by the Web Form Designer.
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()

    End Sub
    Protected WithEvents TextBox1 As System.Web.UI.WebControls.TextBox
    Protected WithEvents Button1 As System.Web.UI.WebControls.Button

    'NOTE: The following placeholder declaration is required by the Web Form Designer.
    'Do not delete or move it.
    Private designerPlaceholderDeclaration As System.Object

    Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
        'CODEGEN: This method call is required by the Web Form Designer
        'Do not modify it using the code editor.
        InitializeComponent()
    End Sub

#End Region

    Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        'Put user code to initialize the page here
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Response.Write("something")
        TextBox1.Text = "something"
    End Sub
End Class


planoie May 28th, 2004 12:57 PM

The page/server never SHOULD access the aspx.vb file. Putting that on the server is pointless. Again, I think you are missing the point. The aspx.vb file contains code that is compiled into an assembly. The fact that the file is named the same as the web page with the additional .vb suffix is completely unrelated to the functioning of ASP.NET. The name (and the attributes regarding "CodeBehind" are for the benefit of visual studio, so it knows how to associate the files in the UI. You could just as easily have a vb faile called abcxyz.vb with a class that inherits from System.Web.UI.Page. Then your ASPX could have Inherits="Assg2.TheClassICreated" and the page would still work.

The point is that all the .vb files are the source for the DLL. They don't need to (and really shouldn't) be on the server. So the problem you are having has nothing to do with the files that are on the server.

I can't see what the problem is in your code. It looks fine to me.

X-Ken May 28th, 2004 02:15 PM

but if i don't put the classThatICreate.vb on the server, how will the button's action be taken? because I see that the button 'onclick' event is stored in the class.vb.
As in the example, will the Response.write("test") work when i click button1 if i don't put the class.vb into the server?


X-Ken May 28th, 2004 02:19 PM

Should I merge WebForm1.aspx.vb into WebForm1.aspx?


planoie June 1st, 2004 01:14 PM

Do you understand the concept of compiled code? You are obviously running VS.net, and perhaps you are getting confused by what you perceive as running locally and what is really running.

Here are the files that are used for constructing a page:
mypage.aspx - This is the actual page that the browser requests
mypage.aspx.vb - This is a code-behind file that neither the browser or server care about.

How it works (assuming a vb.net web application):
In VS.net, when you "run" the application, VS compiles the application. What this means is that it takes all the files in the web application project that are marked as "Compile" (usually anything ending in .vb) and compiles them ALL into a SINGLE assembly (.DLL file).

mypage.aspx.vb --> mywebapplication.dll

What happens when it actually RUNS:
- Browser requests page "mypage.aspx"
- ASP.net handles the processing of the aspx page and expects to be able to inherit from the class "mypage" (this is what the "inherits" attribute is in the @ Page directive)
- The class "mypage" exists inside of the DLL.
- ASP.net runs the page with the necessary class that it gets from the DLL

What this all means:
The .vb file(s) do not actually have to live with the .aspx file. However, the DLL file that is generated DOES have to live with the .aspx files, inside the application's /bin directory. When you deploy pages to another server, you only need to deploy the page itself (.aspx) and the assembly that contains any required classes (.dll). If you don't have the dll, you will this error:

Parser Error Message: Could not load type 'mywebapplication.mypage'.

If you do NOT get this error, but things still do not work, then there are other problems.

X-Ken June 3rd, 2004 11:06 AM

ohh.. now it works!

Thanks Peter, your my hero



All times are GMT -4. The time now is 11:47 AM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.