473,320 Members | 1,922 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,320 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 4589
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: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.