Quantcast

CodeBehind tag from VS.NET

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

CodeBehind tag from VS.NET

Gavin Hamill
Hi - I'm a little curious on this one... Microsoft VS.NET generates .aspx
pages whose first line is similar to:

<%@ Page language="c#" Codebehind="WebForm1.aspx.cs"
AutoEventWireup="false" .....

If I try to run this directly with mod_mono and Apache, I'll get a scary big
error:

Error message: Cannot find type WebApplication1.WebForm1

Yet if I simply change the keyword 'Codebehind' to 'src', the application runs
perfectly.

 http://www.mono-project.com/FAQ:_ASP.NET#Does_Mono_support_code-behind_in_ASP.NET.3

This FAQ says : "That [Codebehind] attribute is ignored by MS and Mono parsing
code" - then why does the app run on IIS but not on Mono, if both
environments ignore the tag?

It'd just be nice to not have to make changes to source to 'make it Mono
compliant' since .NET should be .NET :)

Cheers,
Gavin.
_______________________________________________
Mono-list maillist  -  [hidden email]
http://lists.ximian.com/mailman/listinfo/mono-list
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: CodeBehind tag from VS.NET

Robert Jordan
Gavin,

> Hi - I'm a little curious on this one... Microsoft VS.NET generates .aspx
> pages whose first line is similar to:
>
> <%@ Page language="c#" Codebehind="WebForm1.aspx.cs"
> AutoEventWireup="false" .....
>
> If I try to run this directly with mod_mono and Apache, I'll get a scary big
> error:
>
> Error message: Cannot find type WebApplication1.WebForm1
>
> Yet if I simply change the keyword 'Codebehind' to 'src', the application runs
> perfectly.
>
>  http://www.mono-project.com/FAQ:_ASP.NET#Does_Mono_support_code-behind_in_ASP.NET.3
>
> This FAQ says : "That [Codebehind] attribute is ignored by MS and Mono parsing
> code" - then why does the app run on IIS but not on Mono, if both
> environments ignore the tag?

Because Visual Studio compiles the codebehind file for you.

> It'd just be nice to not have to make changes to source to 'make it Mono
> compliant' since .NET should be .NET :)

You don't need to change the file containing the codebehind attribute.
What you have to do is: compile the codebehind file and put the assembly
into the bin folder of the ASP app.

Rob

_______________________________________________
Mono-list maillist  -  [hidden email]
http://lists.ximian.com/mailman/listinfo/mono-list
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Re: CodeBehind tag from VS.NET

Gavin Hamill
On Wednesday 06 July 2005 07:52, Robert Jordan wrote:

Hi Robert,

> You don't need to change the file containing the codebehind attribute.
> What you have to do is: compile the codebehind file and put the assembly
> into the bin folder of the ASP app.

I thought I did.. e.g.

apachectl stop; killall mono; rm -r /tmp/.wapi; (wait for apache to really
stop); apachectl start

I then copied the whole contents from the Windows XP localhost IIS install to
qax, the Mono machine (all except for the _vti FrontPage dirs)

qax:/usr/share/asp.net-demos/asp/WebApplication1# find
.
./bin
./bin/WebApplication1.dll
./bin/WebApplication1.pdb
./AssemblyInfo.cs
./Global.asax
./Global.asax.cs
./Global.asax.resx
./Web.config
./WebApplication1.csproj
./WebApplication1.csproj.webinfo
./WebForm1.aspx
./WebForm1.aspx.cs
./WebForm1.aspx.resx

So as you can see, the .dll is already there in the bin directory, yet running
the WebForm1.aspx from a browser just comes back with:

Server Error in '/samples' Application
Parser Error
Description: Error parsing a resource required to service this request. Review
your source file and modify it to fix this error.
Error message: Cannot find type WebApplication1.WebForm1
File name:  /usr/share/asp.net-demos/asp/WebApplication1/WebForm1.aspx    
Line: 1
Source Error:
<%@ Page language="c#" Codebehind="WebForm1.aspx.cs" AutoEventWireup="false"
Inherits="WebApplication1.WebForm1" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
        <HEAD>

Cheers,
Gavin.
_______________________________________________
Mono-list maillist  -  [hidden email]
http://lists.ximian.com/mailman/listinfo/mono-list
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Re: CodeBehind tag from VS.NET

Adrian Dinu
Did you declare your app as being a mono application?

you need to do that in mod_mono.conf

Sample configuration:

MonoApplications "/WebApplication1:/usr/share/asp.net-demos/asp/WebApplication1"
        <Directory /usr/share/asp.net-demos/asp/WebApplication1>
                Options -Indexes
                <IfModule mod_access.c>
                        Order allow,deny
                        Allow from all
                </IfModule>
                <IfModule mod_dir.c>
                        DirectoryIndex index.aspx
                </IfModule>
        </Directory>

otherwise, it will try to find the required dll in the bin directory of the default mono application that was defined in the config file.


On Wed, 2005-07-06 at 09:26 +0100, Gavin Hamill wrote:
On Wednesday 06 July 2005 07:52, Robert Jordan wrote:

Hi Robert,

> You don't need to change the file containing the codebehind attribute.
> What you have to do is: compile the codebehind file and put the assembly
> into the bin folder of the ASP app.

I thought I did.. e.g.

apachectl stop; killall mono; rm -r /tmp/.wapi; (wait for apache to really 
stop); apachectl start

I then copied the whole contents from the Windows XP localhost IIS install to 
qax, the Mono machine (all except for the _vti FrontPage dirs)

qax:/usr/share/asp.net-demos/asp/WebApplication1# find
.
./bin
./bin/WebApplication1.dll
./bin/WebApplication1.pdb
./AssemblyInfo.cs
./Global.asax
./Global.asax.cs
./Global.asax.resx
./Web.config
./WebApplication1.csproj
./WebApplication1.csproj.webinfo
./WebForm1.aspx
./WebForm1.aspx.cs
./WebForm1.aspx.resx

So as you can see, the .dll is already there in the bin directory, yet running 
the WebForm1.aspx from a browser just comes back with:

Server Error in '/samples' Application
Parser Error
Description: Error parsing a resource required to service this request. Review 
your source file and modify it to fix this error. 
Error message: Cannot find type WebApplication1.WebForm1 
File name:  /usr/share/asp.net-demos/asp/WebApplication1/WebForm1.aspx    
Line: 1 
Source Error: 
<%@ Page language="c#" Codebehind="WebForm1.aspx.cs" AutoEventWireup="false" 
Inherits="WebApplication1.WebForm1" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
        <HEAD>

Cheers,
Gavin.
_______________________________________________
Mono-list maillist  -  [hidden email]
http://lists.ximian.com/mailman/listinfo/mono-list



Adrian Dinu
Technical Manager
Dream Team Software

_______________________________________________
Mono-list maillist  -  [hidden email]
http://lists.ximian.com/mailman/listinfo/mono-list
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Re: CodeBehind tag from VS.NET

Gavin Hamill
On Wednesday 06 July 2005 09:37, Adrian Dinu wrote:
> Did you declare your app as being a mono application?

> otherwise, it will try to find the required dll in the bin directory of
> the default mono application that was defined in the config file.

<click!>

That was the missing link - thank you, Adrian :) I was indeed using a subdir
of the asp.net-samples dir, and then had a 'bin' directory underneath that..
when I just copied the dll to the main 'bin' directory, the application ran
perfectly.

At least I now have a better understanding of how everything pieces
together :)

cheers,
Gavin.
_______________________________________________
Mono-list maillist  -  [hidden email]
http://lists.ximian.com/mailman/listinfo/mono-list
Loading...