Question

I'm trying to develop an agent/client that will listen to HTTP requests on a given port, and serve a simple ASP.Net page. To that end, I'm using the HttpListener and ApplicationHost classes.

I've added a simple page to my project (mypage.aspx). When it contained all the code in the single file, all worked well (tested it by adding <% Response.Write(DateTime.Now.ToString()); %> to the HTML in the page, and observing the timestamp in the browser).

I then proceeded to add a single button to it, add a code-behind file (mypage.aspx.cs) and created a designer file (mypage.aspx.designer.cs) manually. I've added <%@ Page Language="C#" AutoEventWireup="true" Codebehind="SearchForm.aspx.cs" Inherits="MyNameSpace.MyPage" %> to the .aspx file and verified all compiles well.

When trying to access the web page from the browser, I get the following error:

Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately.

Parser Error Message: Could not load type 'MyNameSpace.MyPage'.

Source Error:

Line 1: <%@ Page Language="C#" AutoEventWireup="true" Codebehind="MyPage.aspx.cs" Inherits="MyNameSpace.MyPage" %>

I found out that this means my code-behind has not been compiled, or that that application cannot find the assembly. All my "bin" directory contains is the .exe and .pdb of my original application - no .dll for the .aspx.

I tried the solution offered in this question and verified my .aspx and .cs files were marked for "compile" build action - to no avail.

My question is: how do I cause an .aspx file to compile in a regular WinForm application? Can I do it, or will I have to resort to adding a web application to my solution?

Was it helpful?

Solution

Check out Cassini. It's a web server that has been build awhile back by the ASP.NET team to allow Visual Studio to debug web applications without needing IIS. It's also a standalone web server. The source can be found on Dmitry's blog at http://blogs.msdn.com/dmitryr/archive/2006/03/09/548131.aspx

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top