Search code examples
c#server-sidehttplistener

C# httplistener that parses <% c# %> code


I was wondering if it was possible to setup the HttpListener to process normal C# <%%> code? So essentially I have a programming running an HttpListener right now, and all it does is replace $varname with whatever variable I want to output.

What I would like to do is to use a type of server side script to access all the different variables and methods in my application.

Is such a thing possible?

I looked a bit into Microsoft.CSharp.CSharpCodeProvider but I was thinking there might be a built in way that I'm not aware of.

Essentially I have an application that is a server for a client-server app, and I want to add a web gui to it so that I can call methods, and get variables and such.

Thanks.


Solution

  • You may take a look at the following article. It illustrates how you could use an HttpListener to host the ASP.NET runtime and be able to process ASPX pages. It uses an HttpListenerContext and an HttpWorkerRequest.