473,770 Members | 1,841 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Execute a string of code as if it were a page

Hi,

I wondering if it is possible in asp.net to somehow execute a string
of code as if it were a page on the server. That is to say, if I
executed the following code which resided in an aspx page

<html>
<body>
<% Response.Write( "Hi.") %>
</body>
</html>

the output would be

<html>
<body>
Hi
</body>
</html>

Is there some way I could execute the asp.net from above without it
being in an actual page? Can I send some server method a string and
get the output?

Thanks for any help,

Nick
Nov 18 '05 #1
2 1375
TJS
build the string , populate it with dynamic content and use,
response.write( "mystring")

"nick" <ni**********@h otmail.com> wrote in message
news:30******** *************** ***@posting.goo gle.com...
Hi,

I wondering if it is possible in asp.net to somehow execute a string
of code as if it were a page on the server. That is to say, if I
executed the following code which resided in an aspx page

<html>
<body>
<% Response.Write( "Hi.") %>
</body>
</html>

the output would be

<html>
<body>
Hi
</body>
</html>

Is there some way I could execute the asp.net from above without it
being in an actual page? Can I send some server method a string and
get the output?

Thanks for any help,

Nick

Nov 18 '05 #2
Hey Nick,
Not directly...

What you can do though is create a file on disk, then use Server.Execute( )
to 'run' that page. You can delete it when you're done.

IOW:

Take your string
dump to file with ASPX extensino
Server.Execute( ) to the page with an HtmlTextWriter
Return retrieve the HtmlTextWriter and the result string
Delete the page you created

Be aware though that this causes memory to be used as this new class (the
ASPX) page is created and compiled into an assembly and laoded. If you did
this a lot during processing you'd eat up memory really quickly.

What you should do instead is build a few generic pages that you can use
over and over and do some sort of processing inside those pages that might
be more dynamic.
+++ Rick ---

--

Rick Strahl
West Wind Technologies
http://www.west-wind.com/
http://www.west-wind.com/webblog/
----------------------------------
Making waves on the Web
"nick" <ni**********@h otmail.com> wrote in message
news:30******** *************** ***@posting.goo gle.com...
Hi,

I wondering if it is possible in asp.net to somehow execute a string
of code as if it were a page on the server. That is to say, if I
executed the following code which resided in an aspx page

<html>
<body>
<% Response.Write( "Hi.") %>
</body>
</html>

the output would be

<html>
<body>
Hi
</body>
</html>

Is there some way I could execute the asp.net from above without it
being in an actual page? Can I send some server method a string and
get the output?

Thanks for any help,

Nick

Nov 18 '05 #3

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

Similar topics

6
3544
by: JT | last post by:
is it possible to somehow "jump out of" an ASP page that is executed from another page via the Server.Execute method? on the page being executed i have several instances where i need to stop the execution and immediately shoot back to the calling page without running through the rest of the code on the executed page. im not sure if this is possible but any help would be much appreciated. tia
2
2097
by: Elie Grouchko | last post by:
Hi All I am using Application.lock to protect a reference to a COM+ object while calling Server.Execute() to another ASP page. I am doing this to pass the object's reference to the other page, and I CAN'T rely on the session object. Is this a safe way to protect the object reference? i.e. does the Application object remain locked when calling Server.Execute() ?
3
6877
by: Chris | last post by:
I have yet to understand or get a response on the issue I'm having. I'm taking an asp web application and migrating it from Windows 2K to 2003. I have the new website location (2003) settings correct, i.e. enable parent paths, etc. and still get these errors: Server object error 'ASP 0228 : 80004005' Server.Execute Error /ASP_Procedures/PageHeader.asp, line 60 The call to Server.Execute failed while loading the page.
4
4323
by: Paul | last post by:
Hello, I tried to execute a button on an aspx webpage using WebRequest, but it failed. When posting data as if I did a login (see code), I just receive the login page, instead of the page I should get after login. The button I tried to 'push' (by adding &login=Login in de posted data, where login is the name of the login button - I verified this data by capturing the data of a request using a webbrowser) has not executed.
4
7882
by: Chris | last post by:
I posted this in the C# language group, then thought it might be more appropriate in this group. I would not cross-post except I want the answer so badly. I built small C# Web and Web Service applications in a training class last week. The applications worked in the class, but when I tried to run them again over the weekend, they both bombed. Instead of getting my Web page, or the Web Service page, I get a page full of error text...
3
1752
by: Sophos | last post by:
Hi, I have a basic aspx page, in the Page_Init procedure I have a server.execute of another aspx page that adds some html code to my first page. However it also adds a control (an htmlimage), now my question is how to I get access to that control from the class in my first page? Whenever I try to access it I get a "object reference not set to an instance..." error. Thank you,
2
3338
by: Dune | last post by:
I'm trying to execute an aspx page by calling Server.Execute. The aspx page I'm trying to execute is in a different web app from the aspx page containing the Server.Execute statement. A slightly clearer explanation... Page1 exists in WebApp1. In the code-behind of Page2 in WebApp2, I have put Server.Execute("Path to Page1 in WebApp1"). When I call Server.Execute(String) using "http://localhost/WebApp1/Page1.aspx", everything works ok...
4
4065
by: Ian Kelly | last post by:
Hi All, I have an .net form that is split into two frames. The left frame has a tree that displays a list of all the customers. The right frame displays the appropriate clients information. When the save button is pressed on the right frame, I want to update the tree in the left frame AFTER saving all the data as the changes to the right frame may affect how the tree is displayed. I tried using the following: ...
0
1073
by: Brian | last post by:
I'm using Server.Execute to decide at run-time which .aspx page to use to format a mail message. Using a StringWriter, I call Server.Execute on the page that does the formatting, then snag the text from the StringWriter and stuff it into an email message. All these pages use a custom Page class that we've written to handle the startup/shutdown stuff and provide access to our business objects. That is, caller.aspx and callee.apsx both...
0
9453
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10099
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 captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10036
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 most users, this new feature is actually very convenient. If you want to control the update process,...
0
8929
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 launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6710
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5354
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 the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5481
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4007
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3607
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.