Rectangle 27 2

I'd do it as a web application project.

  • It's compiled as part of deployment. This will catch most of the fat fingered typing errors.
  • (and this is my real one): Web Site Projects are a complete pain in the * for team development. To the point that even for a stupid simple little app that only I will ever work on I still refuse to click on the New -> Web Site menu option.

There are multiple reasons to dislike "Web Site" projects; and extremely few to bother with them. So, IMHO, just stick with Web App projects or use an MVC flavor of the month.

ASP.NET Project for an ASHX file - Stack Overflow

asp.net ashx
Rectangle 27 8

Ask the user, do not guess. Have a setting for it in your web application.

I think it is ok to guess the default setting that works ok, say, 95% of the time. What I meant was that the user should still be able to override whatever guesses the software made. I've been frustrated too many times already when a software tries to be too smart and does not allow to be corrected.

Funny, it was my first idea, but I went overboard looking how to do it automatically...

Bad idea, except maybe as a backup. Most users are embarassinlgy culture-insensitive and won't even understand what a "decimal separator" is without explanation (and then will be pissed off at being forced to set something that "everyone knows").

@Iaalto: this would make a question almost as great as "Minimize database size (recommended) or Maximize search capabilities?"

Well, that shouldn't be too hard. Just let the user choose the country and then select the desicmal separator and other options accordingly.

html - With a browser, how do I know which decimal separator does the ...

html internationalization locale
Rectangle 27 233

This is a maven error. It says that it is expecting a web.xml file in your project because it is a web application, as indicated by <packaging>war</packaging>. However, for recent web applications a web.xml file is totally optional. Maven needs to catch up to this convention. Add this to your maven pom.xml to let maven catch up and you don't need to add a useless web.xml to your project:

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-war-plugin</artifactId>
            <version>2.6</version>
            <configuration>
                <failOnMissingWebXml>false</failOnMissingWebXml>
            </configuration>
        </plugin>
    </plugins>
</build>

This is a better solution than adding an empty web.xml because this way your final product stays clean, your are just changing your build parameters.

For more current versions of maven you can also use the shorter version:

<properties>
    <failOnMissingWebXml>false</failOnMissingWebXml>
</properties>

If you are using a in Servlet 3.0+ environment and have any implementation of a Interface WebApplicationInitializer this answer is the correct approach. It's the sensible way to solve this problem - no point adding the web.xml after taking steps to live without it!

I would mark as solution...

Please consider updating your answer for a shorter configuration, as suggested below. Including <properties><failOnMissingWebXml>false</failOnMissingWebXml></properties> suffices instead of the more verbose plugin configuration settings.

eclipse - web.xml is missing and is set to true ...

eclipse maven java-ee m2eclipse
Rectangle 27 6

I had a pretty big ASP.NET web site (not a web application) and wanted to add MVC3 to it. I had no option to change the type of the project so I had to go with the web site (asp.net 4.0).

I use a separate MVC project but not as it's own web application but as an assembly within my old web site.

Here's a rundown of what I did:

  • I created a new MVC3 web application in Visual Studio 2010, I used the empty template and the Razor view engine.
  • I changed the output path for the assembly from the local bin directory to the bin directory of my web site.
  • I removed the 'Content' and 'Scripts' folders from the MVC app. Both content and scripts are already part of my web site and I can reference these from MVC 'pages' as well.
  • I removed the Global.asax.* files from the project. I am using the Global.asax in the web site.
  • I copied the 'Views' folder and subfolders over to the web site. Because these are actual files and not part of the assembly, they have to exist within the web site not the project that builds the MVC assembly.
  • At this point I could have deleted the 'Views' folder from the MVC project but it is only in this project type that I get Visual Studio support for adding a new view. So I sometimes create a view here and then move it over to the web site. When editing the cshtml files in my web site, I still get full Intellisense.

Added Routing to the web site. I just copied over some code from an MVC global.asax in the global.asax of my web site. We need some usings:

using System.Web.Mvc;
using System.Web.Routing;
AreaRegistration.RegisterAllAreas();
    RegisterGlobalFilters(GlobalFilters.Filters);
    RegisterRoutes(RouteTable.Routes);

Then add the usual routing methods:

public static void RegisterGlobalFilters(GlobalFilterCollection filters)
    {
        filters.Add(new HandleErrorAttribute());
    }

    public static void RegisterRoutes(RouteCollection routes)
    {
        routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

        // your routes
    }

Next add a few things to the web.config of your web site. In system.web under compilation we need the following assemblies:

<assemblies>
        <add assembly="System.Web.Abstractions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
        <add assembly="System.Web.Helpers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
        <add assembly="System.Web.Routing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
        <add assembly="System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
        <add assembly="System.Web.WebPages, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
      </assemblies>

You do now create new routes in Global.asax of the web site, then add a corresponding controller in the MVC project and then back to the web site to add a view for it. So you logic is all in a assembly while the views and the routing is defined in the web site.

You can still debug into the MVC controllers by setting break points there, but you debug by starting the web site.

If you use the suggested default route of MVC:

routes.MapRoute("Default", "{controller}/{action}/{id}", 
            new { controller = "Home", action = "Index", id = UrlParameter.Optional }
        );

a call to www.mysite.com will serve up the content of the home controller/view not your old default.aspx home page, so I just don't use such a route. If you routes conflict with existing physical folders and files, use constraints with regular expressions on the routes to exclude such conflicts.

Even though I use master pages in the web site, the actual html for the common page parts is created by code in another assembly. I could just call the same methods from my _ViewStart.cshtml or my base controller.

So far I have not seen any real negative about this approach.

How would you sprinkle-in ASP.Net MVC into an existing Web Site Projec...

asp.net asp.net-mvc visual-studio web-site-project
Rectangle 27 7

If you are in a web application which already uses Spring and if you do not want to include Apache Commons IO for simple file copying, you can use FileCopyUtils of the Spring framework.

Standard concise way to copy a file in Java? - Stack Overflow

java file copy
Rectangle 27 3

Thus, Java is probably the wrong end to fix this problem when you are in a web application context (like facebook).

I'd go for javascript. Since Javascript is not my primary field of interest, I can't really judge if this is a good solution, but it might give you a pointer.

+1 agree. I can't comment on the JavaScript either, but it highlights the need to address the problem in the view. As an aside, I'd use "" fileformat.info/info/unicode/char/2026/index.htm

java - Ideal method to truncate a string with ellipsis - Stack Overflo...

java ellipsis
Rectangle 27 3

Thus, Java is probably the wrong end to fix this problem when you are in a web application context (like facebook).

I'd go for javascript. Since Javascript is not my primary field of interest, I can't really judge if this is a good solution, but it might give you a pointer.

+1 agree. I can't comment on the JavaScript either, but it highlights the need to address the problem in the view. As an aside, I'd use "" fileformat.info/info/unicode/char/2026/index.htm

java - Ideal method to truncate a string with ellipsis - Stack Overflo...

java ellipsis
Rectangle 27 3

Thus, Java is probably the wrong end to fix this problem when you are in a web application context (like facebook).

I'd go for javascript. Since Javascript is not my primary field of interest, I can't really judge if this is a good solution, but it might give you a pointer.

+1 agree. I can't comment on the JavaScript either, but it highlights the need to address the problem in the view. As an aside, I'd use "" fileformat.info/info/unicode/char/2026/index.htm

java - Ideal method to truncate a string with ellipsis - Stack Overflo...

java ellipsis
Rectangle 27 3

Thus, Java is probably the wrong end to fix this problem when you are in a web application context (like facebook).

I'd go for javascript. Since Javascript is not my primary field of interest, I can't really judge if this is a good solution, but it might give you a pointer.

+1 agree. I can't comment on the JavaScript either, but it highlights the need to address the problem in the view. As an aside, I'd use "" fileformat.info/info/unicode/char/2026/index.htm

java - Ideal method to truncate a string with ellipsis - Stack Overflo...

java ellipsis
Rectangle 27 8

If you had the web application up and running before, there may be an old debug server that did not close down properly running in the background. See this post about how to find what process that uses port 1099. If it proves to be a java process, kill it.

(If you use the GUI sw suggested in the link above, you may kill the process(es) by marking all java processes that uses port 1099, right click and press "End Process...")

I fully favor this answer. Typically there is a java.exe process that I need to kill, which is the previous tomcat process still running. Killing this process resolves the problem.

+1 for "If you had the web application up and running before, there may be an old debug server that did not close down properly running in the background" which was exactly my case - thanks

java - Cannot start Apache Tomcat 6 from IntelliJ IDEA 12.1.4 Ultimate...

java tomcat intellij-idea tomcat6
Rectangle 27 8

If you had the web application up and running before, there may be an old debug server that did not close down properly running in the background. See this post about how to find what process that uses port 1099. If it proves to be a java process, kill it.

(If you use the GUI sw suggested in the link above, you may kill the process(es) by marking all java processes that uses port 1099, right click and press "End Process...")

I fully favor this answer. Typically there is a java.exe process that I need to kill, which is the previous tomcat process still running. Killing this process resolves the problem.

+1 for "If you had the web application up and running before, there may be an old debug server that did not close down properly running in the background" which was exactly my case - thanks

java - Cannot start Apache Tomcat 6 from IntelliJ IDEA 12.1.4 Ultimate...

java tomcat intellij-idea tomcat6
Rectangle 27 150

Web Site is what you deploy to an ASP.NET web server such as IIS. Just a bunch of files and folders. Theres nothing in a Web Site that ties you to Visual Studio (theres no project file). Code-generation and compilation of web pages (such as .aspx, .ascx, .master) is done dynamically at runtime, and changes to these files are detected by the framework and automatically re-compiled. You can put code that you want to share between pages in the special App_Code folder, or you can pre-compile it and put the assembly in the Bin folder.

The main difference with Web Sites is that when you build the project all the code files are compiled into a single assembly, which is placed in the bin directory. You dont deploy code files to the web server.

Deploying shared code files is generally a bad idea, but that doesnt mean you have to choose Web Application. You can have a Web Site that references a class library project that holds all the code for the Web Site. Web Applications is just a convenient way to do it.

By having all code files compiled into a single assembly, including codebehind files of .aspx pages and .ascx controls, in Web Applications you have to re-build for every little change, and you cannot make live changes. This can be a real pain during development, since you have to keep re-building to see the changes, while with Web Sites changes are detected by the runtime and pages/controls are automatically recompiled.

Having the runtime manage the codebehind assemblies is less work for you, since you don't need to worry about giving pages/controls unique names, or organizing them into different namespaces.

Im not saying deploying code files is always a good idea (specially not in the case of shared code files), but codebehind files should only contain code that perform UI specific tasks, wire-up events handlers, etc. Your application should be layered so that important code always end up in the Bin folder. If that is the case then deploying codebehind files shouldn't be considered harmful.

Another limitation of Web Applications is that you can only use the language of the project. In Web Sites you can have some pages in C#, some in VB, etc. No need for special Visual Studio support. Thats the beauty of the build provider extensibility.

Also, in Web Applications you don't get error detection in pages/controls as the compiler only compiles your codebehind classes and not the markup code (in MVC you can fix this using the MvcBuildViews option), which is compiled at runtime.

Because Web Applications are Visual Studio projects you get some features not available in Web Sites. For instance, you can use build events to perform a variety of tasks, e.g. minify and/or combine Javascript files.

Building a Web Application is faster than building a Web Site, specially for large sites. This is mainly because Web Applications do not compile the markup code. In MVC if you set MvcBuildViews to true then it compiles the markup code and you get error detection, which is very useful. The down side is that every time you build the solution it builds the complete site, which can be slow and inefficient, specially if you are not editing the site. l find myself turning MvcBuildViews on and off (which requires a project unload). On the other hand, with Web Sites you can choose if you want to build the site as part of the solution or not. If you choose not to, then building the solution is very fast, and you can always click on the Web Site node and select Build, if youve made changes.

In an MVC Web Application project you have extra commands and dialogs for common tasks, like Add View, Go To View, Add Controller, etc. These are not available in an MVC Web Site.

If you use IIS Express as the development server, in Web Sites you can add virtual directories. This option is not available in Web Applications.

Because the programmers write the application, the application is then built. The test team tests the application on the test system. Then the customer installs the applications. That LAST think you want is anyone making live changes!

I'm not saying making live changes is good or bad, just that webapp projects doesn't support them.

Which is a good thing IMHO. It makes a mockery of any code, test, release process which has to be the bedrock of any serious application

To me having the choice is the best, on websites you can always inherit from a pre-compiled base class if you want to. There are many languages/frameworks (e.g. PHP) where people are used to the idea of deploying source code. That doesn't mean those are not 'serious' applications.

"Actually, you don't manage those DLL's, [...] you don't even have to know they exists. Not an issue." - Until the framework gets confused, doesn't clean the old versions up correctly, and starts throwing compilation exceptions with conflicting names all over the site... You can add error detection of the markup through the use of a WebDeployment project. I'm also not sure on your last point "with websites you can use IIS as the server", you can do this with a Web Application as well - and I have projects like this where the project is part of a larger web application.

.net - ASP.NET Web Site or ASP.NET Web Application? - Stack Overflow

asp.net .net visual-studio projects-and-solutions
Rectangle 27 11

Well, it converts your web site to a web application project. As for the advantages, here is some further reading:

The primary difference (to me) between a web application project and a web site is how things gets compiled. In web sites each page has its code-behind compiled into a separate library, whereas in web applications all code-behind gets compiled into a single library.

There are advantages and disadvantages to both, it really depends. It's also often a matter of opinion.

c# - What does the option "convert to web application" do if I select ...

c# asp.net visual-studio
Rectangle 27 11

Well, it converts your web site to a web application project. As for the advantages, here is some further reading:

The primary difference (to me) between a web application project and a web site is how things gets compiled. In web sites each page has its code-behind compiled into a separate library, whereas in web applications all code-behind gets compiled into a single library.

There are advantages and disadvantages to both, it really depends. It's also often a matter of opinion.

c# - What does the option "convert to web application" do if I select ...

c# asp.net visual-studio
Rectangle 27 151

Web Site is what you deploy to an ASP.NET web server such as IIS. Just a bunch of files and folders. Theres nothing in a Web Site that ties you to Visual Studio (theres no project file). Code-generation and compilation of web pages (such as .aspx, .ascx, .master) is done dynamically at runtime, and changes to these files are detected by the framework and automatically re-compiled. You can put code that you want to share between pages in the special App_Code folder, or you can pre-compile it and put the assembly in the Bin folder.

The main difference with Web Sites is that when you build the project all the code files are compiled into a single assembly, which is placed in the bin directory. You dont deploy code files to the web server.

Deploying shared code files is generally a bad idea, but that doesnt mean you have to choose Web Application. You can have a Web Site that references a class library project that holds all the code for the Web Site. Web Applications is just a convenient way to do it.

By having all code files compiled into a single assembly, including codebehind files of .aspx pages and .ascx controls, in Web Applications you have to re-build for every little change, and you cannot make live changes. This can be a real pain during development, since you have to keep re-building to see the changes, while with Web Sites changes are detected by the runtime and pages/controls are automatically recompiled.

Having the runtime manage the codebehind assemblies is less work for you, since you don't need to worry about giving pages/controls unique names, or organizing them into different namespaces.

Im not saying deploying code files is always a good idea (specially not in the case of shared code files), but codebehind files should only contain code that perform UI specific tasks, wire-up events handlers, etc. Your application should be layered so that important code always end up in the Bin folder. If that is the case then deploying codebehind files shouldn't be considered harmful.

Another limitation of Web Applications is that you can only use the language of the project. In Web Sites you can have some pages in C#, some in VB, etc. No need for special Visual Studio support. Thats the beauty of the build provider extensibility.

Also, in Web Applications you don't get error detection in pages/controls as the compiler only compiles your codebehind classes and not the markup code (in MVC you can fix this using the MvcBuildViews option), which is compiled at runtime.

Because Web Applications are Visual Studio projects you get some features not available in Web Sites. For instance, you can use build events to perform a variety of tasks, e.g. minify and/or combine Javascript files.

Building a Web Application is faster than building a Web Site, specially for large sites. This is mainly because Web Applications do not compile the markup code. In MVC if you set MvcBuildViews to true then it compiles the markup code and you get error detection, which is very useful. The down side is that every time you build the solution it builds the complete site, which can be slow and inefficient, specially if you are not editing the site. l find myself turning MvcBuildViews on and off (which requires a project unload). On the other hand, with Web Sites you can choose if you want to build the site as part of the solution or not. If you choose not to, then building the solution is very fast, and you can always click on the Web Site node and select Build, if youve made changes.

In an MVC Web Application project you have extra commands and dialogs for common tasks, like Add View, Go To View, Add Controller, etc. These are not available in an MVC Web Site.

If you use IIS Express as the development server, in Web Sites you can add virtual directories. This option is not available in Web Applications.

Because the programmers write the application, the application is then built. The test team tests the application on the test system. Then the customer installs the applications. That LAST think you want is anyone making live changes!

I'm not saying making live changes is good or bad, just that webapp projects doesn't support them.

Which is a good thing IMHO. It makes a mockery of any code, test, release process which has to be the bedrock of any serious application

To me having the choice is the best, on websites you can always inherit from a pre-compiled base class if you want to. There are many languages/frameworks (e.g. PHP) where people are used to the idea of deploying source code. That doesn't mean those are not 'serious' applications.

"Actually, you don't manage those DLL's, [...] you don't even have to know they exists. Not an issue." - Until the framework gets confused, doesn't clean the old versions up correctly, and starts throwing compilation exceptions with conflicting names all over the site... You can add error detection of the markup through the use of a WebDeployment project. I'm also not sure on your last point "with websites you can use IIS as the server", you can do this with a Web Application as well - and I have projects like this where the project is part of a larger web application.

.net - ASP.NET Web Site or ASP.NET Web Application? - Stack Overflow

asp.net .net visual-studio projects-and-solutions
Rectangle 27 150

Web Site is what you deploy to an ASP.NET web server such as IIS. Just a bunch of files and folders. Theres nothing in a Web Site that ties you to Visual Studio (theres no project file). Code-generation and compilation of web pages (such as .aspx, .ascx, .master) is done dynamically at runtime, and changes to these files are detected by the framework and automatically re-compiled. You can put code that you want to share between pages in the special App_Code folder, or you can pre-compile it and put the assembly in the Bin folder.

The main difference with Web Sites is that when you build the project all the code files are compiled into a single assembly, which is placed in the bin directory. You dont deploy code files to the web server.

Deploying shared code files is generally a bad idea, but that doesnt mean you have to choose Web Application. You can have a Web Site that references a class library project that holds all the code for the Web Site. Web Applications is just a convenient way to do it.

By having all code files compiled into a single assembly, including codebehind files of .aspx pages and .ascx controls, in Web Applications you have to re-build for every little change, and you cannot make live changes. This can be a real pain during development, since you have to keep re-building to see the changes, while with Web Sites changes are detected by the runtime and pages/controls are automatically recompiled.

Having the runtime manage the codebehind assemblies is less work for you, since you don't need to worry about giving pages/controls unique names, or organizing them into different namespaces.

Im not saying deploying code files is always a good idea (specially not in the case of shared code files), but codebehind files should only contain code that perform UI specific tasks, wire-up events handlers, etc. Your application should be layered so that important code always end up in the Bin folder. If that is the case then deploying codebehind files shouldn't be considered harmful.

Another limitation of Web Applications is that you can only use the language of the project. In Web Sites you can have some pages in C#, some in VB, etc. No need for special Visual Studio support. Thats the beauty of the build provider extensibility.

Also, in Web Applications you don't get error detection in pages/controls as the compiler only compiles your codebehind classes and not the markup code (in MVC you can fix this using the MvcBuildViews option), which is compiled at runtime.

Because Web Applications are Visual Studio projects you get some features not available in Web Sites. For instance, you can use build events to perform a variety of tasks, e.g. minify and/or combine Javascript files.

Building a Web Application is faster than building a Web Site, specially for large sites. This is mainly because Web Applications do not compile the markup code. In MVC if you set MvcBuildViews to true then it compiles the markup code and you get error detection, which is very useful. The down side is that every time you build the solution it builds the complete site, which can be slow and inefficient, specially if you are not editing the site. l find myself turning MvcBuildViews on and off (which requires a project unload). On the other hand, with Web Sites you can choose if you want to build the site as part of the solution or not. If you choose not to, then building the solution is very fast, and you can always click on the Web Site node and select Build, if youve made changes.

In an MVC Web Application project you have extra commands and dialogs for common tasks, like Add View, Go To View, Add Controller, etc. These are not available in an MVC Web Site.

If you use IIS Express as the development server, in Web Sites you can add virtual directories. This option is not available in Web Applications.

Because the programmers write the application, the application is then built. The test team tests the application on the test system. Then the customer installs the applications. That LAST think you want is anyone making live changes!

I'm not saying making live changes is good or bad, just that webapp projects doesn't support them.

Which is a good thing IMHO. It makes a mockery of any code, test, release process which has to be the bedrock of any serious application

To me having the choice is the best, on websites you can always inherit from a pre-compiled base class if you want to. There are many languages/frameworks (e.g. PHP) where people are used to the idea of deploying source code. That doesn't mean those are not 'serious' applications.

"Actually, you don't manage those DLL's, [...] you don't even have to know they exists. Not an issue." - Until the framework gets confused, doesn't clean the old versions up correctly, and starts throwing compilation exceptions with conflicting names all over the site... You can add error detection of the markup through the use of a WebDeployment project. I'm also not sure on your last point "with websites you can use IIS as the server", you can do this with a Web Application as well - and I have projects like this where the project is part of a larger web application.

.net - ASP.NET Web Site or ASP.NET Web Application? - Stack Overflow

asp.net .net visual-studio projects-and-solutions
Rectangle 27 150

Web Site is what you deploy to an ASP.NET web server such as IIS. Just a bunch of files and folders. Theres nothing in a Web Site that ties you to Visual Studio (theres no project file). Code-generation and compilation of web pages (such as .aspx, .ascx, .master) is done dynamically at runtime, and changes to these files are detected by the framework and automatically re-compiled. You can put code that you want to share between pages in the special App_Code folder, or you can pre-compile it and put the assembly in the Bin folder.

The main difference with Web Sites is that when you build the project all the code files are compiled into a single assembly, which is placed in the bin directory. You dont deploy code files to the web server.

Deploying shared code files is generally a bad idea, but that doesnt mean you have to choose Web Application. You can have a Web Site that references a class library project that holds all the code for the Web Site. Web Applications is just a convenient way to do it.

By having all code files compiled into a single assembly, including codebehind files of .aspx pages and .ascx controls, in Web Applications you have to re-build for every little change, and you cannot make live changes. This can be a real pain during development, since you have to keep re-building to see the changes, while with Web Sites changes are detected by the runtime and pages/controls are automatically recompiled.

Having the runtime manage the codebehind assemblies is less work for you, since you don't need to worry about giving pages/controls unique names, or organizing them into different namespaces.

Im not saying deploying code files is always a good idea (specially not in the case of shared code files), but codebehind files should only contain code that perform UI specific tasks, wire-up events handlers, etc. Your application should be layered so that important code always end up in the Bin folder. If that is the case then deploying codebehind files shouldn't be considered harmful.

Another limitation of Web Applications is that you can only use the language of the project. In Web Sites you can have some pages in C#, some in VB, etc. No need for special Visual Studio support. Thats the beauty of the build provider extensibility.

Also, in Web Applications you don't get error detection in pages/controls as the compiler only compiles your codebehind classes and not the markup code (in MVC you can fix this using the MvcBuildViews option), which is compiled at runtime.

Because Web Applications are Visual Studio projects you get some features not available in Web Sites. For instance, you can use build events to perform a variety of tasks, e.g. minify and/or combine Javascript files.

Building a Web Application is faster than building a Web Site, specially for large sites. This is mainly because Web Applications do not compile the markup code. In MVC if you set MvcBuildViews to true then it compiles the markup code and you get error detection, which is very useful. The down side is that every time you build the solution it builds the complete site, which can be slow and inefficient, specially if you are not editing the site. l find myself turning MvcBuildViews on and off (which requires a project unload). On the other hand, with Web Sites you can choose if you want to build the site as part of the solution or not. If you choose not to, then building the solution is very fast, and you can always click on the Web Site node and select Build, if youve made changes.

In an MVC Web Application project you have extra commands and dialogs for common tasks, like Add View, Go To View, Add Controller, etc. These are not available in an MVC Web Site.

If you use IIS Express as the development server, in Web Sites you can add virtual directories. This option is not available in Web Applications.

Because the programmers write the application, the application is then built. The test team tests the application on the test system. Then the customer installs the applications. That LAST think you want is anyone making live changes!

I'm not saying making live changes is good or bad, just that webapp projects doesn't support them.

Which is a good thing IMHO. It makes a mockery of any code, test, release process which has to be the bedrock of any serious application

To me having the choice is the best, on websites you can always inherit from a pre-compiled base class if you want to. There are many languages/frameworks (e.g. PHP) where people are used to the idea of deploying source code. That doesn't mean those are not 'serious' applications.

"Actually, you don't manage those DLL's, [...] you don't even have to know they exists. Not an issue." - Until the framework gets confused, doesn't clean the old versions up correctly, and starts throwing compilation exceptions with conflicting names all over the site... You can add error detection of the markup through the use of a WebDeployment project. I'm also not sure on your last point "with websites you can use IIS as the server", you can do this with a Web Application as well - and I have projects like this where the project is part of a larger web application.

.net - ASP.NET Web Site or ASP.NET Web Application? - Stack Overflow

asp.net .net visual-studio projects-and-solutions
Rectangle 27 150

Web Site is what you deploy to an ASP.NET web server such as IIS. Just a bunch of files and folders. Theres nothing in a Web Site that ties you to Visual Studio (theres no project file). Code-generation and compilation of web pages (such as .aspx, .ascx, .master) is done dynamically at runtime, and changes to these files are detected by the framework and automatically re-compiled. You can put code that you want to share between pages in the special App_Code folder, or you can pre-compile it and put the assembly in the Bin folder.

The main difference with Web Sites is that when you build the project all the code files are compiled into a single assembly, which is placed in the bin directory. You dont deploy code files to the web server.

Deploying shared code files is generally a bad idea, but that doesnt mean you have to choose Web Application. You can have a Web Site that references a class library project that holds all the code for the Web Site. Web Applications is just a convenient way to do it.

By having all code files compiled into a single assembly, including codebehind files of .aspx pages and .ascx controls, in Web Applications you have to re-build for every little change, and you cannot make live changes. This can be a real pain during development, since you have to keep re-building to see the changes, while with Web Sites changes are detected by the runtime and pages/controls are automatically recompiled.

Having the runtime manage the codebehind assemblies is less work for you, since you don't need to worry about giving pages/controls unique names, or organizing them into different namespaces.

Im not saying deploying code files is always a good idea (specially not in the case of shared code files), but codebehind files should only contain code that perform UI specific tasks, wire-up events handlers, etc. Your application should be layered so that important code always end up in the Bin folder. If that is the case then deploying codebehind files shouldn't be considered harmful.

Another limitation of Web Applications is that you can only use the language of the project. In Web Sites you can have some pages in C#, some in VB, etc. No need for special Visual Studio support. Thats the beauty of the build provider extensibility.

Also, in Web Applications you don't get error detection in pages/controls as the compiler only compiles your codebehind classes and not the markup code (in MVC you can fix this using the MvcBuildViews option), which is compiled at runtime.

Because Web Applications are Visual Studio projects you get some features not available in Web Sites. For instance, you can use build events to perform a variety of tasks, e.g. minify and/or combine Javascript files.

Building a Web Application is faster than building a Web Site, specially for large sites. This is mainly because Web Applications do not compile the markup code. In MVC if you set MvcBuildViews to true then it compiles the markup code and you get error detection, which is very useful. The down side is that every time you build the solution it builds the complete site, which can be slow and inefficient, specially if you are not editing the site. l find myself turning MvcBuildViews on and off (which requires a project unload). On the other hand, with Web Sites you can choose if you want to build the site as part of the solution or not. If you choose not to, then building the solution is very fast, and you can always click on the Web Site node and select Build, if youve made changes.

In an MVC Web Application project you have extra commands and dialogs for common tasks, like Add View, Go To View, Add Controller, etc. These are not available in an MVC Web Site.

If you use IIS Express as the development server, in Web Sites you can add virtual directories. This option is not available in Web Applications.

Because the programmers write the application, the application is then built. The test team tests the application on the test system. Then the customer installs the applications. That LAST think you want is anyone making live changes!

I'm not saying making live changes is good or bad, just that webapp projects doesn't support them.

Which is a good thing IMHO. It makes a mockery of any code, test, release process which has to be the bedrock of any serious application

To me having the choice is the best, on websites you can always inherit from a pre-compiled base class if you want to. There are many languages/frameworks (e.g. PHP) where people are used to the idea of deploying source code. That doesn't mean those are not 'serious' applications.

"Actually, you don't manage those DLL's, [...] you don't even have to know they exists. Not an issue." - Until the framework gets confused, doesn't clean the old versions up correctly, and starts throwing compilation exceptions with conflicting names all over the site... You can add error detection of the markup through the use of a WebDeployment project. I'm also not sure on your last point "with websites you can use IIS as the server", you can do this with a Web Application as well - and I have projects like this where the project is part of a larger web application.

.net - ASP.NET Web Site or ASP.NET Web Application? - Stack Overflow

asp.net .net visual-studio projects-and-solutions
Rectangle 27 150

Web Site is what you deploy to an ASP.NET web server such as IIS. Just a bunch of files and folders. Theres nothing in a Web Site that ties you to Visual Studio (theres no project file). Code-generation and compilation of web pages (such as .aspx, .ascx, .master) is done dynamically at runtime, and changes to these files are detected by the framework and automatically re-compiled. You can put code that you want to share between pages in the special App_Code folder, or you can pre-compile it and put the assembly in the Bin folder.

The main difference with Web Sites is that when you build the project all the code files are compiled into a single assembly, which is placed in the bin directory. You dont deploy code files to the web server.

Deploying shared code files is generally a bad idea, but that doesnt mean you have to choose Web Application. You can have a Web Site that references a class library project that holds all the code for the Web Site. Web Applications is just a convenient way to do it.

By having all code files compiled into a single assembly, including codebehind files of .aspx pages and .ascx controls, in Web Applications you have to re-build for every little change, and you cannot make live changes. This can be a real pain during development, since you have to keep re-building to see the changes, while with Web Sites changes are detected by the runtime and pages/controls are automatically recompiled.

Having the runtime manage the codebehind assemblies is less work for you, since you don't need to worry about giving pages/controls unique names, or organizing them into different namespaces.

Im not saying deploying code files is always a good idea (specially not in the case of shared code files), but codebehind files should only contain code that perform UI specific tasks, wire-up events handlers, etc. Your application should be layered so that important code always end up in the Bin folder. If that is the case then deploying codebehind files shouldn't be considered harmful.

Another limitation of Web Applications is that you can only use the language of the project. In Web Sites you can have some pages in C#, some in VB, etc. No need for special Visual Studio support. Thats the beauty of the build provider extensibility.

Also, in Web Applications you don't get error detection in pages/controls as the compiler only compiles your codebehind classes and not the markup code (in MVC you can fix this using the MvcBuildViews option), which is compiled at runtime.

Because Web Applications are Visual Studio projects you get some features not available in Web Sites. For instance, you can use build events to perform a variety of tasks, e.g. minify and/or combine Javascript files.

Building a Web Application is faster than building a Web Site, specially for large sites. This is mainly because Web Applications do not compile the markup code. In MVC if you set MvcBuildViews to true then it compiles the markup code and you get error detection, which is very useful. The down side is that every time you build the solution it builds the complete site, which can be slow and inefficient, specially if you are not editing the site. l find myself turning MvcBuildViews on and off (which requires a project unload). On the other hand, with Web Sites you can choose if you want to build the site as part of the solution or not. If you choose not to, then building the solution is very fast, and you can always click on the Web Site node and select Build, if youve made changes.

In an MVC Web Application project you have extra commands and dialogs for common tasks, like Add View, Go To View, Add Controller, etc. These are not available in an MVC Web Site.

If you use IIS Express as the development server, in Web Sites you can add virtual directories. This option is not available in Web Applications.

Because the programmers write the application, the application is then built. The test team tests the application on the test system. Then the customer installs the applications. That LAST think you want is anyone making live changes!

I'm not saying making live changes is good or bad, just that webapp projects doesn't support them.

Which is a good thing IMHO. It makes a mockery of any code, test, release process which has to be the bedrock of any serious application

To me having the choice is the best, on websites you can always inherit from a pre-compiled base class if you want to. There are many languages/frameworks (e.g. PHP) where people are used to the idea of deploying source code. That doesn't mean those are not 'serious' applications.

"Actually, you don't manage those DLL's, [...] you don't even have to know they exists. Not an issue." - Until the framework gets confused, doesn't clean the old versions up correctly, and starts throwing compilation exceptions with conflicting names all over the site... You can add error detection of the markup through the use of a WebDeployment project. I'm also not sure on your last point "with websites you can use IIS as the server", you can do this with a Web Application as well - and I have projects like this where the project is part of a larger web application.

.net - ASP.NET Web Site or ASP.NET Web Application? - Stack Overflow

asp.net .net visual-studio projects-and-solutions
Rectangle 27 4

Here is some code I pulled out of an old project I had. It was a web application but I was using iTextSharp to merge pdf files then print them.

public static class PdfMerger
    {
        /// <summary>
        /// Merge pdf files.
        /// </summary>
        /// <param name="sourceFiles">PDF files being merged.</param>
        /// <returns></returns>
        public static byte[] MergeFiles(List<Stream> sourceFiles)
        {
            Document document = new Document();
            MemoryStream output = new MemoryStream();

            try
            {
                // Initialize pdf writer
                PdfWriter writer = PdfWriter.GetInstance(document, output);
                writer.PageEvent = new PdfPageEvents();

                // Open document to write
                document.Open();
                PdfContentByte content = writer.DirectContent;

                // Iterate through all pdf documents
                for (int fileCounter = 0; fileCounter < sourceFiles.Count; fileCounter++)
                {
                    // Create pdf reader
                    PdfReader reader = new PdfReader(sourceFiles[fileCounter]);
                    int numberOfPages = reader.NumberOfPages;

                    // Iterate through all pages
                    for (int currentPageIndex = 1; currentPageIndex <=
                                        numberOfPages; currentPageIndex++)
                    {
                        // Determine page size for the current page
                        document.SetPageSize(
                            reader.GetPageSizeWithRotation(currentPageIndex));

                        // Create page
                        document.NewPage();
                        PdfImportedPage importedPage =
                            writer.GetImportedPage(reader, currentPageIndex);


                        // Determine page orientation
                        int pageOrientation = reader.GetPageRotation(currentPageIndex);
                        if ((pageOrientation == 90) || (pageOrientation == 270))
                        {
                            content.AddTemplate(importedPage, 0, -1f, 1f, 0, 0,
                                reader.GetPageSizeWithRotation(currentPageIndex).Height);
                        }
                        else
                        {
                            content.AddTemplate(importedPage, 1f, 0, 0, 1f, 0, 0);
                        }
                    }
                }
            }
            catch (Exception exception)
            {
                throw new Exception("There has an unexpected exception" +
                        " occured during the pdf merging process.", exception);
            }
            finally
            {
                document.Close();
            }
            return output.GetBuffer();
        }
    }



    /// <summary>
    /// Implements custom page events.
    /// </summary>
    internal class PdfPageEvents : IPdfPageEvent
    {
        #region members
        private BaseFont _baseFont = null;
        private PdfContentByte _content;
        #endregion

        #region IPdfPageEvent Members
        public void OnOpenDocument(PdfWriter writer, Document document)
        {
            _baseFont = BaseFont.CreateFont(BaseFont.HELVETICA,
                                BaseFont.CP1252, BaseFont.NOT_EMBEDDED);
            _content = writer.DirectContent;
        }

        public void OnStartPage(PdfWriter writer, Document document)
        { }

        public void OnEndPage(PdfWriter writer, Document document)
        { }

        public void OnCloseDocument(PdfWriter writer, Document document)
        { }

        public void OnParagraph(PdfWriter writer,
                    Document document, float paragraphPosition)
        { }

        public void OnParagraphEnd(PdfWriter writer,
                    Document document, float paragraphPosition)
        { }

        public void OnChapter(PdfWriter writer, Document document,
                                float paragraphPosition, Paragraph title)
        { }

        public void OnChapterEnd(PdfWriter writer,
                    Document document, float paragraphPosition)
        { }

        public void OnSection(PdfWriter writer, Document document,
                    float paragraphPosition, int depth, Paragraph title)
        { }

        public void OnSectionEnd(PdfWriter writer,
                    Document document, float paragraphPosition)
        { }

        public void OnGenericTag(PdfWriter writer, Document document,
                                    Rectangle rect, string text)
        { }
        #endregion

        private float GetCenterTextPosition(string text, PdfWriter writer)
        {
            return writer.PageSize.Width / 2 - _baseFont.GetWidthPoint(text, 8) / 2;
        }
    }

I didn't write this, but made some modifications. I can't remember where I found it. After I merged the PDFs I would call this method to insert javascript to open the print dialog when the PDF is opened. If you change bSilent to true then it should print silently to their default printer.

public Stream addPrintJStoPDF(Stream thePDF)
{
    MemoryStream outPutStream = null;
    PRStream finalStream = null;
    PdfDictionary page = null;
    string content = null;

    //Open the stream with iTextSharp
    var reader = new PdfReader(thePDF);

    outPutStream = new MemoryStream(finalStream.GetBytes());
    var stamper = new PdfStamper(reader, (MemoryStream)outPutStream);
    var jsText = "var res = app.setTimeOut('this.print({bUI: true, bSilent: false, bShrinkToFit: false});', 200);";
    //Add the javascript to the PDF
    stamper.JavaScript = jsText;

    stamper.FormFlattening = true;
    stamper.Writer.CloseStream = false;
    stamper.Close();

    //Set the stream to the beginning
    outPutStream.Position = 0;

    return outPutStream;
}

Not sure how well the above code is written since I pulled it from somewhere else and I haven't worked in depth at all with iTextSharp but I do know that it did work at merging PDFs that I was generating at runtime.

Please refrain from using this kind of merge routine unless you have very specific requirements forcing you to do that. When you use PdfWriter to merge source PDFs, interactive features (forms and other annotations) are lost. Furthermore the resulting PDF internally contains an unnecessary wrapper around the page information which when iterated multiple times may cause PDF viewers to fail when trying to display the PDF.

As I said I had pulled this from older code that was in production but PDFs were generated from html built by a wysiwyg editor so we had no interactive features. Also our iterations were usually only around 10 at a time and we never had issues with the pdf not opening. I posted this as an example as we had it running in production and I know that it was working to merge pdfs with no reported issues.

I intended no offense; such merging solutions like yours based on PdfWriter indeed can be found more often than the ones using the better suited classes when googling around, and they do work after a fashion, so they are not completely wrong. Pdf*Copy* based solutions, though, generally are easier to use (no need to adapt the target document page size and rotation again and again), more complete (concerning interactive features), and produce cleaner output (with respect to the internal PDF structure).

c# - How to merge multiple pdf files (generated in run time)? - Stack ...

c# asp.net pdf itextsharp rdlc