Run ASP.NET pages outside IIS by Scott Guthrie


Contributed by
Rating: 4 stars4 stars4 stars4 stars4 stars / 7
March 17, 2002
Rate this Article:
MEH MEH++


SEARCH ASP FREE
TOOLS YOU CAN USE

advertisement

One interesting uses of ASP.NET is to "pre-process" dynamic ASP.NET requests - saving the output as static.htm files that can be copied to the web-server. You can do this with MyHost.exe by"piping" the output automatically to a static file. Thiswas originally obtained on Charles Carroll's ASPNGFreeforAll posted by Scott Guthrie from Microsoft.

Note:This example has been updated for RTM v1.0.

For example:

To try this out, perform the following steps:

1) Copy The MyHost.cs, mk.bat and Test.aspx files to a local virtual directory
2) Compile MyHost.exe by running mk.bat "csc MyHost.cs /r:System.Web.dll" within a command prompt in the directory
3) Create a directory called bin in virtual sub-directory and copy the myhost.exe file to the bin directory
4) Type "MyHost.exe Test.aspx > test.htm".

c:inetpubwwwrootMyHost.exe Test.aspx > Test.htm

using System;
using System.IO;
using System.Web;
using System.Web.Hosting;


public class MyExeHost : MarshalByRefObject {

public void ProcessRequest(String page)
{
HttpRuntime.ProcessRequest(new SimpleWorkerRequest(page, null, Console.Out));
}

public static void Main(String[] arguments)
{
MyExeHost host =(MyExeHost)ApplicationHost.CreateApplicationHost(typeof(MyExeHost),"/foo", Environment.CurrentDirectory);
foreach (String page in arguments)
{
host.ProcessRequest(page);
}
}
}


----------------------------------------
Test.asx Code
----------------------------------------


<html>
<body>
Time is now: <%=Now%>
</body>
</html>

----------------------------------------
mk.bat Code
----------------------------------------

csc MyHost.cs /r:System.Web.dll

blog comments powered by Disqus
ASP.NET ARTICLES

- Implementing ASP.NET 4.0 Page.MetaDescriptio...
- ASP.Net Development Tips
- Intro to Sessions in ASP.Net
- Google Maps API Introduction in ASP.NET usin...
- Creating an ASP.NET 3.5 Gridview Image Galle...
- Encrypt QueryString in ASP.NET 3.5 using VB....
- ASP.NET 3.5 Drop Down List Controls
- Connect to Access Database with ASP.Net
- Secure Audio Streaming with ASP.Net and Flash
- Dynamic Sitemap and Navigation in ASP.Net
- Implement Gzip and Deflate Compression in AS...
- Run ASP.Net in Ubuntu with Apache
- ASP.Net Mono Website Contact Forms
- ASP.Net URL Rewriting Methods
- Murach`s ASP.NET 4 Web Programming with C# 2...

ASP Web Hosting ASP.Net Web Hosting Windows Web Hosting
 
 
 

ASP Free Forums 
 RSS  Tutorials RSS
 RSS  Forums RSS
 RSS  All Feeds
Site Map 
Request Media Kit
Write For Us Get Paid 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
Privacy Policy 
Support 


© 2003-2012 by Developer Shed. All rights reserved. DS Cluster 2 - Follow our Sitemap
Most Popular Topics
All ASP.Net Tutorials