locked
Confused about Deployment (ASP.NET Web Application vs ASP.NET Web Site) RRS feed

  • Question

  • User-1995945195 posted

    I am having difficulty publishing my ASP.NET website when my project is of type "ASP.NET Web Application" (I created a new project by File -> New Project -> Visual C# -> ASP.NET Web Application).  When I choose "Publish Web Site", it asks me to select the folder to publish to, which works fine.  I notice, however, in the 'published' default.aspx page (the only page in my project) that it is pointing to "Default.aspx.cs" for the CodeFile, however, the Published web site only has a .DLL in the \bin folder, named [Projectname].DLL, but its not being referenced anywhere or anything.

     I created another project of type "ASP.NET Website", by going to File -> New Website -> ASP.NET Website, used the same source files, did a build, and then published the site, and it works great.

     Any ideas on how/why this is happening? Also, what is the exact difference by an 'ASP.NET Web Application' and an 'ASP.NET Website' when creating a new project?

    Many thanks in advance.

    Saturday, October 25, 2008 4:37 PM

Answers

  • User372121194 posted

    Hi,

    ASP.NET Web Application project (http://msdn.microsoft.com/en-us/asp.net/aa336618.aspx) is closer to the Visual Studio .NET 2003 Web Project model and compiles all of the source code files during the build process and generates a single assembly in the local /bin directory for deployment. After we use Publish feature to publish web application, we can remove the "CodeFile" from Page directive, instead, CLR uses Inherits to load type.

    In ASP.NET Website project, the compiler will remove CodeFile attribute and change the Inherits attribute to include the assembly name.

    This is by design.

     

    I look forward to hearing from you.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, October 28, 2008 2:49 AM

All replies

  • User372121194 posted

    Hi,

    ASP.NET Web Application project (http://msdn.microsoft.com/en-us/asp.net/aa336618.aspx) is closer to the Visual Studio .NET 2003 Web Project model and compiles all of the source code files during the build process and generates a single assembly in the local /bin directory for deployment. After we use Publish feature to publish web application, we can remove the "CodeFile" from Page directive, instead, CLR uses Inherits to load type.

    In ASP.NET Website project, the compiler will remove CodeFile attribute and change the Inherits attribute to include the assembly name.

    This is by design.

     

    I look forward to hearing from you.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, October 28, 2008 2:49 AM
  • User-1995945195 posted

     Thank you for the reply.  So, if I am starting a new project in Visual Studio 2008, I shouldn't choose "Web Application Project" but instead should choose "ASP.NET Web Site" every time?

    Tuesday, November 4, 2008 3:57 PM
  • User372121194 posted

    Hi,

    Thanks for your response.

    They are both working. You can choose the one you prefer to work with.

     

    Thanks.

    Tuesday, November 4, 2008 9:05 PM
  • User-1995945195 posted

    I am still having difficulty with an ASP.NET Web Application.  I created a new project, and it created a Default.aspx page (as well as the .cs codebehind page).  I just created a sample label and in the CodeBehind I assigned a string to the label Text property.  I built the page and ran it from Visual Studio, and it works.

    I then tried using the 'Publish' command and I published it to a folder on my computer.  That folder now has a default.aspx file, but no more .aspx.cs file as it compiled it in a .DLL file in the Bin folder.  However, when I open up that Default.aspx file that was 'published', in the Page directive it is still trying to reference "CodeBehind=Default.aspx.cs".  However, obviously since it is now compiled that file is not there, instead there is a DLL file in the \Bin folder.

     a) How do I fix this so that it properly references that DLL file that was compiled and published?

    b) How do I set it up so that every time I compile/publish the project it doesn't show the CodeBehind=Default.aspx.cs anymore in the Page directive since obviously it doesn't exist?

     Thanks.

    Wednesday, November 5, 2008 12:11 PM
  • User-1630397707 posted

    I am having the same problem in VS2008. I have been pounding my head against the keyboard for some time now trying to get this to work. I tried publishing using the option "All Project files" and that works fine. But since everything I've read insists that this is a one-click solution, I manually deleted all the file from the destination directory and published the project again with the "Only files needed to run this application" and out of nowhere it started working. I can't explain why though. Any other insight into the matter would be appreciated.

     For what it's worth, the web application .aspx file still shows "<%@ Page Language="C#" AutoEventWireup="true" Codebehind="MyPageName.aspx.cs" Inherits="MyNamespace.MyPageName" %>"

    Friday, November 7, 2008 1:07 PM
  • User-1995945195 posted

     *bump*

     any help would be greatly appreciated.

    Friday, January 9, 2009 10:55 AM
  • User20803155 posted

    Change CodeFile to Codebehind on your form then the deployment will work.

    This works for all types of web projects.

    Cheerio Jeremy

    Friday, February 13, 2009 7:50 AM
  • User-1995945195 posted

    I am bumping this up because I am still having difficulty.  I created a new ASP.NET Web Application, with just one file (default.aspx).  I saved it, compiled it, and used the "Publish" option.  I chose the default option, "Copy Only files needed to run this application", and saved it to a folder.  However, when I look at the default.aspx file, it is trying to access the default.aspx.cs codebehind file, but it doesn't exist since it wasn't published.

    If I publish using the "Copy All Project Files"  option, it does copy ALL the project files, including the codebehind.  However, I was under the assumption that the whole point of ASP.NET when you compile is that you don't have access to the source code when you publish it? 

    What is the proper way to deploy/publish "ASP.NET Web Application" types in VS2008? I am really confused.

    Many thanks for any help.

    Monday, June 15, 2009 7:13 PM
  • User-105429085 posted

    I just solved a connect question which referenced this post.

    In summary:

    Web application  project (new project->Web application) uses CodeBehind

    Web Site project (new web site) uses CodeFile

    They should not be mixed, as our project will have hard time to determine them during package and deployment time.

    Hope it helps.

    Thanks.

    Tuesday, April 20, 2010 6:29 PM
  • User-105429085 posted

    http://vishaljoshi.blogspot.com/2009/08/web-application-project-vs-web-site.html will help you to decide which model to use. 

    Tuesday, April 20, 2010 6:31 PM
  • User707731979 posted

    Here I'll explain you the difference between web application and website:

    Websites are usually referred to as a group of all files in a meticulous folder and sub folders. Files like word documents, text files, images etc are the elements of the website that are stored in a detailed folder.  You will not find any project file produced routinely. It is required to supervise all the accessible files incorporating source files to the server. During the run time, these files have to be compiled dynamically. You also require to know that in order to generate a website, it is a must to develop the menu File > New > Website. Other than that, you will also be offered with an option to choose either file System, Http or FTP.

    The first option facilitates the person to opt for a folder to store all the files, but the other substitute lets one to choose a virtual directory in order to put the files. The concluding favorite is to select an ftp location. Even the visual studio will maintain all the files in one folder that is dedicated to a website, due to which no single assembly will be shaped. There will also be no "Bin" folder. It is actually advantageous as there is no need to have a project file or virtual directory while breach a project. This model is actually practical throughout the time of sharing or downloading code from the net. All that you require to do is copy the downloaded code into a folder. Microsoft came up with this concept thinking that it will be useful for the development team.

    Coming to web application, originally the development community did not give connotation to numerous accessible web applications that enabled the individuals to contentedly access the "project" based application. The reason at the back of the failure of the model was because many unnecessary files were put in frequent web applications under the website folder. As the demand for the newer version was needed, Microsoft introduced "Visual Studio 2005 Web Application Projects" on April 7, 2006. It was an Add-On to Visual Studio 2005 that helped people to create and operate web applications in a manner that was used in the Visual Studio 2003.

    There is no major difference in the Visual Studio 2005 Web Application Project and the Visual Studio .NET 2003 Web Project because the previous model makes use of the same project, assemble and compilation method as that of the latter model. Later, the code files that are produced during the project are collected in a single assembly, which is created and copied in the Bin directory. Finally, these files are classified in a project file because if the files are accessible within the web's file-system root are not distinct in the project file, then they are not regarded as a part of the web project.

    Web applications are popular due to the seeming to be of web browsers, and the expediency of using a web browser as a client, sometimes called a thin client. The capability to update and preserve web applications without distributing and installing software on potentially thousands of client computers is a key reason for their popularity, as is the inbuilt support for cross-platform compatibility. Common web applications contain webmail, online retail sales, online auctions, wikis and many other functions.

    Wednesday, June 30, 2010 6:49 AM