VirtualPathProvider and Application Restart

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Sriram Srivatsan

    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.Host ing.VirtualPath Provider. 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 "numRecompilesB eforeAppRestart ".

    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 numRecompilesBe foreAppRestart -- 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
    VirtualPathProv ider 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
    GetCacheDepende ncy 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 ClientBuildMana ger 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
    ClientBuildMana ger. 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.

    A broad category of Microsoft tools, languages, and frameworks for software development. Designed to support developers in building, debugging, and deploying applications across various platforms.



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

    Kris


  • Sriram Srivatsan

    #2
    Re: VirtualPathProv ider and Application Restart

    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 numRecompilesBe foreAppRestart
    limit is reached. Note the VirtualPathProv ider is using the same compiling
    engine, therefore this limitation also applies.


    Best regards,

    Walter Wang

    Microsoft Online Community Support



    "Sriram Srivatsan" <sriramsrivatsa n@srasys.co.inw rote in message
    news:ufUIMe4%23 IHA.3396@TK2MSF TNGP03.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.Host ing.VirtualPath Provider. 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 "numRecompilesB eforeAppRestart ".
    >
    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 numRecompilesBe foreAppRestart -- 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
    VirtualPathProv ider 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 GetCacheDepende ncy 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 ClientBuildMana ger 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
    ClientBuildMana ger. 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.
    >
    A broad category of Microsoft tools, languages, and frameworks for software development. Designed to support developers in building, debugging, and deploying applications across various platforms.


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

    Comment

    Working...