473,396 Members | 1,706 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,396 software developers and data experts.

VirtualPathProvider and Application Restart

Hi

We are trying to build an application where we render some of the .aspx
pages from the database using a class derived from
System.Web.Hosting.VirtualPathProvider. Users configure the contents of the
page at runtime via the web interface and we do a XSLT transformation and
store the contents of the .aspx pages in the database. The .aspx pages are
hooked to a well known code behind in an assembly that is deployed as a
assembly in the bin folder of the web site.using the @Page inherits
attribute. None of the contents are wired up using the autoeventwireup =
true but the code behind is a generic class that is written in such a way
that it has the intelligence to subscribe to events etc.

This approach is pretty similar to what is given here:

http://kbalertz.com/910441/virtual-p...ual-paths.aspx.

The PROBLEM! Asp.NET worker process restart. This depends on the entry in
the web.config file "numRecompilesBeforeAppRestart".

We want to avoid the asp.net worker process to restart itself as other
users of the application would loose the session state (which is In-Proc at
the moment) when the asp.net worker process unloads the application domain.

We use .NET framework 2.0 and VS2005 to do all this along with SQL Server
2005.

A couple of things that I already know may hack this up (dont want to do)

1. I can increase the numRecompilesBeforeAppRestart -- but this is
probably not a good idea since this would not make the problem go away.
Users would still experience this problem whenever asp.net does restart
itself.
2. I can make the session stored in the state server and write a back end
job to remove the session; or write a HttpModule to somehow remove the
session from the database -- this is a big performance hit as sessions
stored in the database would make things slower
3. I could as an alternative, dynamically load controls on the page.,
instead of doing things the way we do now. However, this would again
degrade performance and also increase complexity.
What we dont know

1. Is this approach conceptually flawed or is this ok? If so what are we
missing out? (The GetFileHash() override implementation of the
VirtualPathProvider that we have right now returns a new hash code each time
the contents of the database for the .aspx changes. We return a null for the
GetCacheDependency since we cant have a dependency to detect if the file
content of the .aspx has changed)
2. Is there a possibility of using the ClientBuildManager to precompile a
..aspx file when we generate the .aspx file -- maybe if the .aspx is already
precompiled, when the user requests for a page, the appdomain will NOT
unload itself? We do know that asp.net does a compilation when the user
requests for a page. What if we do the compilation using the
ClientBuildManager. And the user requests for the page AFTER the
application does the compilation?

Please let us know what you think if you can as we have tried to post here
to no avail and am not sure what I am missing anymore! I do have your phone
number but decided that it would be impolite to give you a call before
sending you an email.

http://forums.asp.net/p/1301629/2540774.aspx#2540774
http://www.opinionatedgeek.com/Blog/...BlogEntry.aspx

Many thanks in advance. Anticipating your reply anxiously... I hope I am
clear as to what I wanted to convey...

Kris
Aug 11 '08 #1
1 4592
I had sent an email to Walter Wang of Microsoft Online Community Support who
wrote this in reply to what I had asked. Thanks once again Walter., as now
atleast I can move forward. Since I have no other choice, I decided to move
the session state to the Database Server and move a lot of lightweight
things to a cookie. Also, I guess I will write a HttpModule to detect when
the user logs out etc to remove the record for the Session Id from the
Database.

Hi Sriram,
I'm afraid there's no way to workaround this automatic restarting. You see,
once an assembly has been loaded into the default AppDomain, there's no way
to unload it from the AppDomain. When you update an ASPX file, a new
assembly (maybe batch compiled with other changed ASPX files) will get
generated and loaded into the AppDomain. That means some obsolete copies of
assemblies are loaded in the AppDomain and wasting memory. The ASP.NET
engine has to restart the AppDomain once the numRecompilesBeforeAppRestart
limit is reached. Note the VirtualPathProvider is using the same compiling
engine, therefore this limitation also applies.
Best regards,

Walter Wang

Microsoft Online Community Support

"Sriram Srivatsan" <sr*************@srasys.co.inwrote in message
news:uf****************@TK2MSFTNGP03.phx.gbl...
Hi

We are trying to build an application where we render some of the .aspx
pages from the database using a class derived from
System.Web.Hosting.VirtualPathProvider. Users configure the contents of
the page at runtime via the web interface and we do a XSLT transformation
and store the contents of the .aspx pages in the database. The .aspx
pages are hooked to a well known code behind in an assembly that is
deployed as a assembly in the bin folder of the web site.using the @Page
inherits attribute. None of the contents are wired up using the
autoeventwireup = true but the code behind is a generic class that is
written in such a way that it has the intelligence to subscribe to events
etc.

This approach is pretty similar to what is given here:

http://kbalertz.com/910441/virtual-p...ual-paths.aspx.

The PROBLEM! Asp.NET worker process restart. This depends on the entry
in the web.config file "numRecompilesBeforeAppRestart".

We want to avoid the asp.net worker process to restart itself as other
users of the application would loose the session state (which is In-Proc
at the moment) when the asp.net worker process unloads the application
domain.

We use .NET framework 2.0 and VS2005 to do all this along with SQL Server
2005.

A couple of things that I already know may hack this up (dont want to do)

1. I can increase the numRecompilesBeforeAppRestart -- but this is
probably not a good idea since this would not make the problem go away.
Users would still experience this problem whenever asp.net does restart
itself.
2. I can make the session stored in the state server and write a back
end job to remove the session; or write a HttpModule to somehow remove the
session from the database -- this is a big performance hit as sessions
stored in the database would make things slower
3. I could as an alternative, dynamically load controls on the page.,
instead of doing things the way we do now. However, this would again
degrade performance and also increase complexity.
What we dont know

1. Is this approach conceptually flawed or is this ok? If so what are we
missing out? (The GetFileHash() override implementation of the
VirtualPathProvider that we have right now returns a new hash code each
time the contents of the database for the .aspx changes. We return a null
for the GetCacheDependency since we cant have a dependency to detect if
the file content of the .aspx has changed)
2. Is there a possibility of using the ClientBuildManager to precompile a
.aspx file when we generate the .aspx file -- maybe if the .aspx is
already precompiled, when the user requests for a page, the appdomain will
NOT unload itself? We do know that asp.net does a compilation when the
user requests for a page. What if we do the compilation using the
ClientBuildManager. And the user requests for the page AFTER the
application does the compilation?

Please let us know what you think if you can as we have tried to post here
to no avail and am not sure what I am missing anymore! I do have your
phone number but decided that it would be impolite to give you a call
before sending you an email.

http://forums.asp.net/p/1301629/2540774.aspx#2540774
http://www.opinionatedgeek.com/Blog/...BlogEntry.aspx

Many thanks in advance. Anticipating your reply anxiously... I hope I
am clear as to what I wanted to convey...

Kris

Aug 11 '08 #2

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

Similar topics

3
by: Pint | last post by:
I would like to know if there is a programatic way to force the Application object to restart. I have a hosted website where I will be unable to control the webserver (eg:iisreset), and I would...
0
by: Kenny | last post by:
Help...wimper.. been trying to get a virtualpathprovider to work and I have to be missing something. I want users to be able to enter something like mydomain.com/userentereddirectory/ and have...
0
by: Pavel Kocar | last post by:
Hi all, how to detect existing .ascx control in Net 2.0? I try to use method in VirtualPathProvider: HostingEnvironment.VirtualPathProvider.FileExists("~/App_UserControls/ucDataPager.ascx");...
1
by: VV | last post by:
I've created virtualpathprovider class in my application. Everything is ok in developer enviroment (asp.net dev server), but when I switch to IIS everything crashes with Server 500 and 404 error....
0
by: forge1968 | last post by:
I want to handle URLs like this on my IIS site: http://localhost/myapp/REST/foo/1 ('REST/foo/1' doesn't exist - I'll dynamically create the content). I have implemented my own...
0
by: Shane | last post by:
Hello, I'm using VirtualPathProvider for a CMS-like system. As soon as I register the VPP I can no longer debug code with a normal Build -- any changes that I've made since the first build are...
5
by: Charles Zhang | last post by:
I am creating dynamic web pages according to the user inputs from a web page. For instance, a user typed in a text, I would want the text being the source code of the dynamic page. My...
1
by: Brian Simmons | last post by:
Hi All, I know that if you modify the web.config file or any file in the App_Code subfolder, that ASP.net 2.0 will "restart" the application (i.e. clear out any sessions, etc...). Are there...
5
by: IUnknown | last post by:
Ok, we are all aware of the situation where modifying the folder structure (adding files, folders, deleting files, etc) will result in ASP.NET triggering a recompilation/restart of the application....
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?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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...
0
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...

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.