473,387 Members | 1,582 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Using code behind without a virtual directory?

I have a C# class GeneralUtilities.cs , which many of my aspx.cs files
will refer to. So, I've put it under the App_Code folder and compiled
it to library using csc /target: library from the DOS console.

I can use objects of type GeneralUtilities in any aspx.cs file in my
web application without any problem if only I make my web application
folder a virtual directory.

If I don't make it a virtual directory, the compiler complains about
GeneralUtilities type or namespace.

But, some other components of this web application refuse to work in a
virtual directory. It takes time to explain, so I will not delve into
this situation.

Right now, I am working around this by putting the GeneralUtilities
class in each single aspx.cs file and de-virtualize the web folder.
This works fine, but it is very tedious to have to put into each
aspx.cs file the same snippet of code, which should otherwise be well
shared from code-behind. It's gonna be even worse if I need to make
big changes to the GeneralUtilities class.

So, I am wondering if there is any way to share code behind without
virtualizing the web folder?

Thanks in advance.

Nov 16 '06 #1
9 2572
Its not so much that its marked as a virtual directory, but that its an
application. In all practicality they are one in the same, but unless its
marked this way, IIS doesn't know to treat it as an application instead of a
subdirectory in the parent app. I would approach this problem from why your
app doesn't work as a virtual directory.

Is it because you have references to folders using "/foldername" and because
its not the root of the website the paths don't match up? If so this can be
fixed using ResolveUrl("~/foldername"), where "~/" is the application's root
directory not the website's.

Just a thought.

"an***********@yahoo.com" wrote:
I have a C# class GeneralUtilities.cs , which many of my aspx.cs files
will refer to. So, I've put it under the App_Code folder and compiled
it to library using csc /target: library from the DOS console.

I can use objects of type GeneralUtilities in any aspx.cs file in my
web application without any problem if only I make my web application
folder a virtual directory.

If I don't make it a virtual directory, the compiler complains about
GeneralUtilities type or namespace.

But, some other components of this web application refuse to work in a
virtual directory. It takes time to explain, so I will not delve into
this situation.

Right now, I am working around this by putting the GeneralUtilities
class in each single aspx.cs file and de-virtualize the web folder.
This works fine, but it is very tedious to have to put into each
aspx.cs file the same snippet of code, which should otherwise be well
shared from code-behind. It's gonna be even worse if I need to make
big changes to the GeneralUtilities class.

So, I am wondering if there is any way to share code behind without
virtualizing the web folder?

Thanks in advance.

Nov 16 '06 #2

Jason Stearns wrote:
Its not so much that its marked as a virtual directory, but that its an
application. In all practicality they are one in the same, but unless its
marked this way, IIS doesn't know to treat it as an application instead of a
subdirectory in the parent app. I would approach this problem from why your
app doesn't work as a virtual directory.

Is it because you have references to folders using "/foldername" and because
its not the root of the website the paths don't match up? If so this can be
fixed using ResolveUrl("~/foldername"), where "~/" is the application's root
directory not the website's.

Just a thought.
Thanks a lot. As a matter of fact, I would rather fix the problem why
some components of my web applicatin refuse to work in a virtual
directory.

OK, so, here is the story.

We are extending an old web application written in classic ASP. We
will write in ASP.NET. Our web users log into the web application from
the classic ASP application.

Then there is the ever-haunting problem of sharing sessions between the
classic ASP application and the ASP.NET application. (Damn Microsoft
which does not also release a bridging facility btwn the two the time
they released ASP.NET).

So, I googled and found this strategy:

http://www.eggheadcafe.com/articles/20021207.asp

and gave it a shot. It works great, but only if transferring the
session objects to the same folder or another folder that is not a web
application or virtual directory itself. Otherwise, the session
objects won't be delievered to the target ASPX page.

That is the problem.

So if there is a good strategy to share session objects between classic
ASP and ASP.NET applications, that would solve this problem.

It looks like the eggheadcafe strategy at the URL above will only
deliever session objects from a classic ASP page to an ASP.NET page
WITHIN the same application. If only it could do so BETWEEN a classic
ASP application and an ASP.NET application, it would also solve the
problem.

The only info we need from the ASP application is the user ID. I do
not think my boss would invest a few hundred bucks for some commercial
bridging package for this purpose.

Your continued help is highly appreciated.

Nov 16 '06 #3
It looks like the eggheadcafe strategy at the URL above will only
deliever session objects from a classic ASP page to an ASP.NET page
WITHIN the same application.
This part sounds correct because of the server.transfer he's using, but even
if you were ok with this you would still need bridging code for every file
that you need for the session variables. If you're going to do that, you
might as well upgrade the whole thing.

I've been in this boat before and the way i got through it was to just
upgrade my classic asp code to asp.net. you could just put each page into
compatability mode, AspCompat="true", so you just have to do the minimum to
upgrade each page.

Not sure there is any easy answer to this.

"an***********@yahoo.com" wrote:
>
Jason Stearns wrote:
Its not so much that its marked as a virtual directory, but that its an
application. In all practicality they are one in the same, but unless its
marked this way, IIS doesn't know to treat it as an application instead of a
subdirectory in the parent app. I would approach this problem from why your
app doesn't work as a virtual directory.

Is it because you have references to folders using "/foldername" and because
its not the root of the website the paths don't match up? If so this can be
fixed using ResolveUrl("~/foldername"), where "~/" is the application's root
directory not the website's.

Just a thought.

Thanks a lot. As a matter of fact, I would rather fix the problem why
some components of my web applicatin refuse to work in a virtual
directory.

OK, so, here is the story.

We are extending an old web application written in classic ASP. We
will write in ASP.NET. Our web users log into the web application from
the classic ASP application.

Then there is the ever-haunting problem of sharing sessions between the
classic ASP application and the ASP.NET application. (Damn Microsoft
which does not also release a bridging facility btwn the two the time
they released ASP.NET).

So, I googled and found this strategy:

http://www.eggheadcafe.com/articles/20021207.asp

and gave it a shot. It works great, but only if transferring the
session objects to the same folder or another folder that is not a web
application or virtual directory itself. Otherwise, the session
objects won't be delievered to the target ASPX page.

That is the problem.

So if there is a good strategy to share session objects between classic
ASP and ASP.NET applications, that would solve this problem.

It looks like the eggheadcafe strategy at the URL above will only
deliever session objects from a classic ASP page to an ASP.NET page
WITHIN the same application. If only it could do so BETWEEN a classic
ASP application and an ASP.NET application, it would also solve the
problem.

The only info we need from the ASP application is the user ID. I do
not think my boss would invest a few hundred bucks for some commercial
bridging package for this purpose.

Your continued help is highly appreciated.

Nov 16 '06 #4

Jason Stearns wrote:
It looks like the eggheadcafe strategy at the URL above will only
deliever session objects from a classic ASP page to an ASP.NET page
WITHIN the same application.

This part sounds correct because of the server.transfer he's using, but even
if you were ok with this you would still need bridging code for every file
that you need for the session variables. If you're going to do that, you
might as well upgrade the whole thing.

I've been in this boat before and the way i got through it was to just
upgrade my classic asp code to asp.net. you could just put each page into
compatability mode, AspCompat="true", so you just have to do the minimum to
upgrade each page.

Not sure there is any easy answer to this.
That sounds easy. But where do you put that directive
(AspCompat="true")? In the ASP.NET page? Will this trick demystify
the whole thing?

Nov 17 '06 #5
<%@ Page aspcompat=true %>

Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
===================================
<an***********@yahoo.comwrote in message
news:11**********************@m7g2000cwm.googlegro ups.com...
>
Jason Stearns wrote:
It looks like the eggheadcafe strategy at the URL above will only
deliever session objects from a classic ASP page to an ASP.NET page
WITHIN the same application.

This part sounds correct because of the server.transfer he's using, but even
if you were ok with this you would still need bridging code for every file
that you need for the session variables. If you're going to do that, you
might as well upgrade the whole thing.

I've been in this boat before and the way i got through it was to just
upgrade my classic asp code to asp.net. you could just put each page into
compatability mode, AspCompat="true", so you just have to do the minimum to
upgrade each page.

Not sure there is any easy answer to this.

That sounds easy. But where do you put that directive
(AspCompat="true")? In the ASP.NET page? Will this trick demystify
the whole thing?

Nov 17 '06 #6
Sorry, yeah, it goes in the page directive. Intellisense should pick up on it
and help you out. However, this isn't the magic bullet either, you'll still
need to do some code upgrading.

check out this article, Scott Mitchell is an ASP/ASP.NET god.
http://www.4guysfromrolla.com/webtech/041601-1.shtml

"an***********@yahoo.com" wrote:
>
Jason Stearns wrote:
It looks like the eggheadcafe strategy at the URL above will only
deliever session objects from a classic ASP page to an ASP.NET page
WITHIN the same application.
This part sounds correct because of the server.transfer he's using, but even
if you were ok with this you would still need bridging code for every file
that you need for the session variables. If you're going to do that, you
might as well upgrade the whole thing.

I've been in this boat before and the way i got through it was to just
upgrade my classic asp code to asp.net. you could just put each page into
compatability mode, AspCompat="true", so you just have to do the minimum to
upgrade each page.

Not sure there is any easy answer to this.

That sounds easy. But where do you put that directive
(AspCompat="true")? In the ASP.NET page? Will this trick demystify
the whole thing?

Nov 17 '06 #7

Jason Stearns wrote:
Sorry, yeah, it goes in the page directive. Intellisense should pick up on it
and help you out. However, this isn't the magic bullet either, you'll still
need to do some code upgrading.

check out this article, Scott Mitchell is an ASP/ASP.NET god.
http://www.4guysfromrolla.com/webtech/041601-1.shtml

"an***********@yahoo.com" wrote:

Jason Stearns wrote:
It looks like the eggheadcafe strategy at the URL above will only
deliever session objects from a classic ASP page to an ASP.NET page
WITHIN the same application.
>
This part sounds correct because of the server.transfer he's using, but even
if you were ok with this you would still need bridging code for every file
that you need for the session variables. If you're going to do that, you
might as well upgrade the whole thing.
>
I've been in this boat before and the way i got through it was to just
upgrade my classic asp code to asp.net. you could just put each page into
compatability mode, AspCompat="true", so you just have to do the minimum to
upgrade each page.
>
Not sure there is any easy answer to this.
That sounds easy. But where do you put that directive
(AspCompat="true")? In the ASP.NET page? Will this trick demystify
the whole thing?
Hi, thanks. But I am not going to upgrade the entire classic ASP
application into ASP.NET. Really, at this moment, the only thing that
needs to be transferred from the ASP application to the ASP.NET
application is the user ID. So, all I need is

(1) Share sessions between classic ASP pages and ASP.NET pages, which
the eggheadcafe strategy does.

(2) In addition to (1), share sessions between two different
applications, which the eggheadcafe strategy does not.

I have problem (1) taken care of with the eggheadcafe trick, but not
sure how to shoot (2).

Nov 17 '06 #8
What I will do to solve this problem is to go up one level, such that I
will be working under the same application which is mix of both classic
ASP and ASP.NET pages.

This has been working fine. Good.

an***********@yahoo.com wrote:
Jason Stearns wrote:
Sorry, yeah, it goes in the page directive. Intellisense should pick up on it
and help you out. However, this isn't the magic bullet either, you'll still
need to do some code upgrading.

check out this article, Scott Mitchell is an ASP/ASP.NET god.
http://www.4guysfromrolla.com/webtech/041601-1.shtml

"an***********@yahoo.com" wrote:
>
Jason Stearns wrote:
It looks like the eggheadcafe strategy at the URL above will only
deliever session objects from a classic ASP page to an ASP.NET page
WITHIN the same application.

This part sounds correct because of the server.transfer he's using, but even
if you were ok with this you would still need bridging code for every file
that you need for the session variables. If you're going to do that, you
might as well upgrade the whole thing.

I've been in this boat before and the way i got through it was to just
upgrade my classic asp code to asp.net. you could just put each page into
compatability mode, AspCompat="true", so you just have to do the minimum to
upgrade each page.

Not sure there is any easy answer to this.
>
That sounds easy. But where do you put that directive
(AspCompat="true")? In the ASP.NET page? Will this trick demystify
the whole thing?
>

Hi, thanks. But I am not going to upgrade the entire classic ASP
application into ASP.NET. Really, at this moment, the only thing that
needs to be transferred from the ASP application to the ASP.NET
application is the user ID. So, all I need is

(1) Share sessions between classic ASP pages and ASP.NET pages, which
the eggheadcafe strategy does.

(2) In addition to (1), share sessions between two different
applications, which the eggheadcafe strategy does not.

I have problem (1) taken care of with the eggheadcafe trick, but not
sure how to shoot (2).
Nov 17 '06 #9
What I will do to solve this problem is to go up one level, such that I
will be working under the same application which is mix of both classic
ASP and ASP.NET pages.

This has been working fine. Good.

an***********@yahoo.com wrote:
Jason Stearns wrote:
Sorry, yeah, it goes in the page directive. Intellisense should pick up on it
and help you out. However, this isn't the magic bullet either, you'll still
need to do some code upgrading.

check out this article, Scott Mitchell is an ASP/ASP.NET god.
http://www.4guysfromrolla.com/webtech/041601-1.shtml

"an***********@yahoo.com" wrote:
>
Jason Stearns wrote:
It looks like the eggheadcafe strategy at the URL above will only
deliever session objects from a classic ASP page to an ASP.NET page
WITHIN the same application.

This part sounds correct because of the server.transfer he's using, but even
if you were ok with this you would still need bridging code for every file
that you need for the session variables. If you're going to do that, you
might as well upgrade the whole thing.

I've been in this boat before and the way i got through it was to just
upgrade my classic asp code to asp.net. you could just put each page into
compatability mode, AspCompat="true", so you just have to do the minimum to
upgrade each page.

Not sure there is any easy answer to this.
>
That sounds easy. But where do you put that directive
(AspCompat="true")? In the ASP.NET page? Will this trick demystify
the whole thing?
>

Hi, thanks. But I am not going to upgrade the entire classic ASP
application into ASP.NET. Really, at this moment, the only thing that
needs to be transferred from the ASP application to the ASP.NET
application is the user ID. So, all I need is

(1) Share sessions between classic ASP pages and ASP.NET pages, which
the eggheadcafe strategy does.

(2) In addition to (1), share sessions between two different
applications, which the eggheadcafe strategy does not.

I have problem (1) taken care of with the eggheadcafe trick, but not
sure how to shoot (2).
Nov 17 '06 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Billy Jacobs | last post by:
I have a website which has both secure and non-secure pages. I want to uses forms authentication. How do I accomplish this? Originally I had my web.config file in the root with Forms...
0
by: Jason Moore | last post by:
I am trying to setup an asp.net web application without using a virtual directory, but when I do, the IDE forces me to use absolute paths so I cannot use root relative paths. Is there a way to...
2
by: Jeffry van de Vuurst | last post by:
Hi, (sorry for the crosspost, I wasn't sure which was the best place to put this). I was just thinking about something and wondered if any of you has some ideas about this. I'm using the...
5
by: Marcel Gelijk | last post by:
Hi, I am trying to create a User Control that is located in a seperate class library. The User Control contains a textbox and a button. The page generates an exception when it tries to access...
0
by: Dwaine | last post by:
I got stumpped on this a while back and used a workaround that involved the "same local username/pwd on both servers" method. Now I'd like to find a cleaner method.... The setup: A webApp...
0
by: mathlec | last post by:
I have 2 WebApplication project (dummy and dummy2). The first is trying to load a UserControl compiled in the second. I've set up the application as follow: \_(Virtual directory) .:Modules:.
7
by: Wayne Wengert | last post by:
I have an ASP.NET (VB) Web Application developed in VS2003. I am totally confused on what needs to get copied to the Web Host when I make some changes. Most of the forms are aspx pages and include...
0
by: clinnebur | last post by:
We have an ASP.NET web application (C#) that copies videos from a CCTV truck to a Linux server. What I am trying to do is convert the .AVI videos(which is how they are created on the truck) to .WMV...
7
by: jain2005k | last post by:
How can I rename a .jpg file in server using asp( not asp.net) code I use the FileSystemObject to do that like Fso = Server.CreateObject("Scripting.FileSystemObject");...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.