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?
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
Related
I tried uploading a simple .HTML webpage as well as a .PHP webpage. They both worked perfectly fine. But when using Visual Studio asp.net and making websites with visual basic, the WebForm.aspx pages created when I publish my projects don't work. I get the error:
Server Error in '/' Application.
Parser 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 'Assignment_1_MattAndrzejczuk.WebForm1'.
Source Error:
Line 1: <%# Page Language="vb" AutoEventWireup="false" CodeBehind="WebForm1.aspx.vb" Inherits="Assignment_1_MattAndrzejczuk.WebForm1" %>
This is for a school assignment, I know for a fact that the web server works and I've tested .HTML and .PHP pages on this web server, they work perfectly fine. But I don't know why I can't do the same with .aspx pages.
Have you set the root folder as an application in IIS? It appears that ASP.NET doesn't know where to go to get to the bin folder.
Schools generally offer Linux environment and their web servers only allow PHP (I think it is because both Linux and PHP are open source). There are plenty of free ASP.NET hostings online.
Regards.
I'm using MS WebDeploy out of Visual Studio 2010 to deploy a ASP.NET 2.0 web forms site. In my source project I have a master page (admin.master) with a code-behind (admin.master.cs).
Following a successful build and deploy on the target site I have:
\bin\myapp.dll
\admin\admin.master
But no admin.master.cs
However I'm not expecting this as I thought the code-behind would now be in the myapp.dll?
When I fire up the site I get the following error:
The file '/admin/admin.master.cs' does not exist.
Line 1: <%# Master Language="C#" AutoEventWireup="true" CodeFile="admin.master.cs" Inherits="admin" %>
Any ideas what is wrong here?
Many thanks,
Sam
Is this a website or web application?
CodeFile="admin.master.cs" would indicate that it's a website, and in that case you would need to include the code behind files.
Seems odd that when you deploy it builds the dll's and removes the code behind files though.
To deploy a website, you can simply use "Copy Web Site".
I have a ASP.Net 3.5 host. I just opened a new, C# Web project in visual studio 2010. I changed customerror to None and delete authentication mode line and select None in server control panel. Project works on local machine and says Hello World when I build and deploy in to server via FTP, I get an error it says Could not Load Type '_Default'
<%# page language="C#" autoeventwireup="true" CodeFile="Default.aspx.cs" inherits="WebApplication._Default" %>
my namespace is WebApplication and in class name is _Default Default.aspx.cs,
It works when I start in ISS, but It cannot start on server.
The error might be coming because you are trying to publish two sites on a single server ftp. It can be solved if you upload it on a sub-domain.
This error is always related to a bad deployment. Either that code file wasn't published or your missing an assembly somewhere.
Also, you might want to check to verify the server does indeed have all of the 3.5 stuff loaded on it.
We had an asp.net 1.1 application that we recently migrated to 3.5. We are facing some problems when we do code modification on the migrated application. Here is what is happening
In the asp.net 1.1 application we have the page directive codebehind="ePC.aspx.cs". This migrated fine.
We made some code changes to the .cs file. Say for example, we added a button and added the event handler to the button.
This new functionality was not getting executed properly.
We changed the codebehind directive to codefile directive
Now it is working fine. But during deployment, it asks that the .cs file also be deployed along with the aspx page. We are not sure why this is happening.
I have attached an example page directive
In VisualStudio with CodeFile
<%# Page language="c#" Codefile="ePC.aspx.cs" AutoEventWireup="True" Inherits="SPUniversal.Web.ePC" %>
After publishing the website
<%# page language="c#" autoeventwireup="True" inherits="SPUniversal.Web.ePC, App_Web_eu_mdesx" %>
The App_Web_eu_mdesx got generated automatically in the published website. I don't understand what is going on here. Can you explain?
For 2.0 sites, you have several options of how ASP.Net handles your web site. You can use default compilation, or pre-compiled sites. If you use default compilation, you need to have the source files on the server because inn this mode, ASP.Net will re-compile the website dynamically if it detects any changes to any of the source .cs or .aspx files.
You may want to look into the pre-compilation options available. By pre-compiling your site when you deploy it, you won't necessarily have to put the .cs files on the server.
I am developing a web application. When I build the application I can see the statement "Build Succeeded" in status bar even the syntax of object declaration is wrong in a aspx.cs file. I cleaned the solution again I tried to rebuild the application. But I did not get any error. If I am adding any block of code in that page it is not executing in run time.
Are you using a Web Site Project or Web Application Project?
I've had to work on a Web Site Project where you'd only get compiler errors at runtime because of the way Web Site Projects handle compilation of code behind.
Hard to assess the exact situation without seeing the structure in the Visual Studio solution. Can you verify that the .aspx page you are working on has its Page directive tag pointing to the correct .aspx.cs code-behind file you are modifying?
<%# Page Language="C#" AutoEventWireup="true" CodeFile="I_AM_MODIFYING_THIS_PAGE.aspx.cs" Inherits="I_AM_MODIFYING_THIS_PAGE" %>