views:

366

answers:

3

Is there a way to make a standalone web application that runs in the tray or something like that using .Net and opens a port with a web server (embedded in the application) using either WebForms or MVC?

+4  A: 

You can run ASP.NET applications using the Cassini web server sample. You can download the source code from http://blogs.msdn.com/dmitryr/archive/2005/09/27/474534.aspx

Cassini is only accessible from the local machine and was the basis for the development web server that comes with Visual Studio. You might want to consider what ports you run this on for users and if the user has overzealous firewall software etc.

BrianLy
A: 

Given your desire to use .Net code the easiest way to get the client side web app is with Silverlight Out of Browser (or "detached" mode)

This lets you connect to the webserver and allows a WPF like gui model.

Here is a sample project.

Silverlight 3 is required.

You cannot place the app in the notification area ("system tray") and you cannot use cross domain services unless they are explicitly marked as such.

ShuggyCoUk
I am not trying to me a web app. I'm trying to make a desktop apps that embeds a web server with a asp.net application inside.
J. Pablo Fernández
Ah - I see I misunderstood your question, BrianLy's sounds like what you want then
ShuggyCoUk
A: 

Sounds like you might want to build a Windows app that has a browser built in. If you make a Windows form and are in design mode then on your Tool Box under "All Windows Forms" is a "WebBrowser" control.

So if I had one of these and named it wbMain, I could do things like:

wbMain.Document.Body.Style = "zoom 40%";
wbMain.Navigate(New Uri(tbURL.Text));
wbMain.CanGoBack = false;
wbMain.CanGoForward = true;

// once I navigate to a page I can play with the page like:
        foreach(HtmlElement HTML In wbMain.Document.Links)
          {
            string Link = HTML.OuterHtml.ToLower;

            if(Link.IndexOf(".mov") > 0 && Link.IndexOf("href=") > 0)
            {... 
               System.Net.WebClient wc = New System.Net.WebClient();
               wc.DownloadFile(MovieLink, Target)

            }                
          }

you get the idea.

JBrooks
Thanks for the code, but my desktop application will have some standard winforms or wpf UI. The web part is that it'll also run a web server for local use by other browsers.
J. Pablo Fernández