473,581 Members | 2,894 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Using code behind without a virtual directory?

I have a C# class GeneralUtilitie s.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 GeneralUtilitie s 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
GeneralUtilitie s 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 GeneralUtilitie s
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 GeneralUtilitie s 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 2583
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 GeneralUtilitie s.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 GeneralUtilitie s 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
GeneralUtilitie s 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 GeneralUtilitie s
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 GeneralUtilitie s 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="tru e")? 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.goog legroups.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
compatabilit y 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="tru e")? 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="tru e")? 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="tru e")? 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***********@y ahoo.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="tru e")? 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***********@y ahoo.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="tru e")? 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
4809
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 Authentication set up and it worked just fine. Then I realized that I needed to have some pages unsecure. I then created 2 directories. One named Secure and...
0
1230
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 setup IIS so that you can use root relative paths without including the name of the virtual directory?
2
4220
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 NetAdvantage component suite from Infragistics for my web applications. When installing they create several virtual
5
3147
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 the code variable that are supposed to be linked to the contained controls. It runs fines when everything is contained in a single web form project....
0
1375
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 (lets say C:\WebApp\) with a subordinate virtual directory (./Images) using an UNC path (e.g. \\ImageServer\Images\ ) to a remote directory, using...
0
1441
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
1102
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 a codebehind file (e.g. myform.aspx and myform.aspx.vb) Normally I do a project rebuild and then a Copy Project with FrontPage option and only...
0
1918
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 in my C# code using Windows Media Encoder. I have a virtual directory to the truck location of the videos. I also have a virtual directory created to...
7
3203
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"); Fso.MoveFile(Server.MapPath("1.jpg"),(Server.MapPath("2.jpg")); but it does not work properly when I use the the code in my local system it also not worked. But when I put...
0
8299
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7890
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
8166
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6546
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5667
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3799
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3813
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1398
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1127
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.