codebehind files in different location

  • Thread starter Thread starter Maurice Walmsley
  • Start date Start date
M

Maurice Walmsley

hi, I hope someone can help me with this please


I'm trying to move my codebehind files to a folder other than the one
my webform sits in. I've tried changing the 'scr' page level attribute
of my webform, but i get the following parser error;

Parser Error Message: 'c:\WebForm2.aspx.vb' is a physical path.

this the code;
<%@ Page Language="vb" AutoEventWireup="false"
src="c:\WebForm2.aspx.vb" Inherits="mywork"%>


Is my syntax for the physical path incorrect? I know it might seem
like a silly question, but what IS the correct syntax? Also, how do i
move this codebehind file?

many thanks

m
 
Try setting the source the same way you would set a link in a web site:

"codebehindfolder/WebForm2.aspx.vb"

Or if the folder is back one folder from the .aspx file:

"../codebehindfolder/WebForm2.aspx.vb"

Sincerely,

--
S. Justin Gengo, MCP
Web Developer

Free code library at:
www.aboutfortunate.com

"Out of chaos comes order."
Nietzche
 
So you have to make your code behind files available on the web (and hope
that IIS filters won't serve them). So much for security...

Jerry
 
Unless there's a bug in the filter. If you could have your code-behind in a
location that's not available on the web (like Maurice is trying to do) you
would not have to worry about this.

Jerry
 
hi all,

thanks for the answers.

I never concidered removing them from the current file to protect them
from web access, but so that I could have my vb files in a central
location (just like classic asp and include files).

I still can't get this to work, though. The issue seems to be with my
use of an absolute path as the src of the codebehind[1] file.

I've tried navigating using relative paths, but get this parser error;
"Cannot use a leading .. to exit above the top directory"

I've tried absolute paths; [src="c:\WebForm2.aspx.vb"], but get;
"Parser Error Message: 'c:\WebForm2.aspx.vb' is a physical path"


The whole point is code 'behind'. I'm sure there is a way to do this,
I just havent found the right syntax/way yet.

cheers

maurice


[1]ofc, the codebehind attrubiute is only used by VS.NET, not the
asp.net page/form itself. The page needs the src attribute.
 
correct me someone if im wrong but I think not because it works for me
if you are doing that for security reasons, then its not necessary
When you build your app, your dll contains the compiled codebehind so you
can erase the ".aspx.vb" if you wish, you dont need them there.
Just leave the .config, .aspx, global.asax and other configuration files

Xavier
Costa Rica
 
Back
Top