By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
458,068 Members | 1,210 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 458,068 IT Pros & Developers. It's quick & easy.

How compile on fly cs file when they are stored in database

P: n/a
I should appeal to your experience to have a suggest as to solve my problem.

I have developed an application using .Net (1.1) where a handler (derived by
IHttpHandler) intercepts every web request beucase the files, formed the
page, are stored in a database.
No problem happens if the page is a pure html: in fact I fetch it from the
database and output it as reponse. If it contains an image (for example), a
new request is fired afterwards. However a problem happens if the page is
..aspx with a related code-behind file (the file .cs is, on its turn, stored
in the database).
In this case I suppose that I have to compile it on fly, but I don't know
the exact sequence of the operations to do.
Must I read the content of the .aspx file, parser the directive <%@ Page
src="..." %>, fetch the .cs file, save it on disk and compile it on fly..?
Have you a bit code as example to solve this drawback with elegance?.

I will be greatful to you for any suggestion forever.
Thanks and best regards.
Maurizio
Nov 19 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Do a search for examples using Reflection.Emit(). This is the way to compile
code "on the fly" in .NET.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

***************************
Think Outside the Box!
***************************
"Maurizio Poletto" wrote:
I should appeal to your experience to have a suggest as to solve my problem.

I have developed an application using .Net (1.1) where a handler (derived by
IHttpHandler) intercepts every web request beucase the files, formed the
page, are stored in a database.
No problem happens if the page is a pure html: in fact I fetch it from the
database and output it as reponse. If it contains an image (for example), a
new request is fired afterwards. However a problem happens if the page is
.aspx with a related code-behind file (the file .cs is, on its turn, stored
in the database).
In this case I suppose that I have to compile it on fly, but I don't know
the exact sequence of the operations to do.
Must I read the content of the .aspx file, parser the directive <%@ Page
src="..." %>, fetch the .cs file, save it on disk and compile it on fly..?
Have you a bit code as example to solve this drawback with elegance?.

I will be greatful to you for any suggestion forever.
Thanks and best regards.
Maurizio

Nov 19 '05 #2

P: n/a

Hi Gregory

My problem is not to compile the file (for this also I can use
Microsoft.CSharp.CSharpCodeProvider class) but the sequence of the operations.
For example I suppose the compiled page must generate a dll and,
conseguently, I must request the aspx page again. But about this..I am not
sure.
Am I pioneer about this need ?.
Ciao

"Cowboy (Gregory A. Beamer) - MVP" wrote:
Do a search for examples using Reflection.Emit(). This is the way to compile
code "on the fly" in .NET.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

***************************
Think Outside the Box!
***************************
"Maurizio Poletto" wrote:
I should appeal to your experience to have a suggest as to solve my problem.

I have developed an application using .Net (1.1) where a handler (derived by
IHttpHandler) intercepts every web request beucase the files, formed the
page, are stored in a database.
No problem happens if the page is a pure html: in fact I fetch it from the
database and output it as reponse. If it contains an image (for example), a
new request is fired afterwards. However a problem happens if the page is
.aspx with a related code-behind file (the file .cs is, on its turn, stored
in the database).
In this case I suppose that I have to compile it on fly, but I don't know
the exact sequence of the operations to do.
Must I read the content of the .aspx file, parser the directive <%@ Page
src="..." %>, fetch the .cs file, save it on disk and compile it on fly..?
Have you a bit code as example to solve this drawback with elegance?.

I will be greatful to you for any suggestion forever.
Thanks and best regards.
Maurizio

Nov 19 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.