CodeFile and Inherits at first line affecting Aspx - asp.net

I developed a simple web application on my localhost successfully. The next step is to port over to a remote server. IIS Manager has been configured and a virtual directory has been set. I have copied 2 files over, the page VB and .aspx file.
On the top of the aspx file, I have <%# Page Language="VB" AutoEventWireup="false" CodeFile="ASPWiki.aspx.vb" Inherits="ASPWiki" %>'. When I try to run, it shows Server Error: 404 File or directory not found.
When i changed it to <%# Page Language="VB" AutoEventWireup="false"%>, the page can be displayed but the asp controls cannot be bind as the mysql coding is at my vb file. Any advice on what is the issue? Could it be due to the binding i used?
The error only happened after the files were placed in the server.

Related

Modifying code in a website on IIS

I have a basic ASP.NET website running under IIS. I didn't publish it, so it's not precompiled or anything.
I was under the impression that if I modify any of the code under any *.aspx.cs file, the site would compile just-in-time and be updated to show those changes.
However, that's not the case. It doesn't reflect my changes and still runs the old code which is in the websitename.dll under the bin folder. Removing that file throws an error.
Is there a way to dynamically modify and run code in an IIS website?
EDIT: the .aspx files do reflect any modifications, it's the .aspx.cs that doesn't work.
It appears that your site is an ASP.NET web application instead of a website. Look at the .aspx file.
In a web application it looks like this:
<%# Page Language="C#" CodeBehind="Default.aspx.cs" Inherits="WebApplication._Default" %>
In a web site it looks like this:
<%# Page Language="C#" CodeFile="Default.aspx.cs" Inherits="_Default" %>
So if your aspx contains CodeFile directive, changes to the code behind will be dynamically picked up.
If it is a web application, you can get rid of the code behind files and any changes would require recompilation.

Parser Error Message: The file '/Site1.Master' does not exist --- but it does

Seems like an easy-to-fix error, but I've been banging my head on this for a while. App works fine in the VS built-in webserver, but not after moving it to the dev server with IIS7.
The default.aspx file refers to the master page in the page directive...
<%# Page Title="" Language="C#" MasterPageFile="~/Site1.Master" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="MyApp.Default" %>
Site1.Master is in the site's root directory, along with default.aspx. The folder permissions are read to Everyone at this point.
This is an intranet site so IIS authorization is anonymous disabled, windows auth enabled, impersonation enabled. App pool is .NET v4, managed pipeline integrated.
I've looked through this site and others for answers and while others have had the same problem, it was for different reasons.
Thanks.
I had the same issue when we moved our site from one server to another. Our new site is on a VPS at a good hosting company (SoftSysHosting.com) and their tech support created a virtual directory of to where our website/app is. That solved it!
I could solve this issue by removing the CodeFile="..." Option in the first line in the Site.Master:
<%# Master Language="C#" AutoEventWireup="true" CodeFile="Site.Master.cs"
inherits="CG.PresentationLayer.WA.MasterPage" %>
into:
<%# Master Language="C#" AutoEventWireup="true" Inherits="MyApp.MasterPage" %>
I have had a similar issue before. The underlying problem is that I assumed that the paths would stay the same and they did not. Log into your dev server and navigate to your master page. Open the page's properties in Explorer and view the path. Now in a test page on your application run a HttpRuntime.AppDomainAppPath() and view where the app is running from. From there you can see where the mismatch is taking place.
Suppose if you are having the root dir of your website or webapplication as given in the pic like "WebApplication1". This is your root folder of the site.
So just copy and paste the content inside the root folder "WebApplication1" to the "root folder" "/" of the FTP address.
Not: dot not copy with root folder WebApplication1. just copy the content inside the root folder.
Your Dir Structure
==+WebApplication1
====Properties
====Referance
====PropertiesSite1.Master
====Web.config
====Webform1.aspx

ASP.NET "Could not Load Type" just on Server

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.

Compile an ASP.Net in a WinForms application

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

Web Deployment

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.

Resources