what is the difference between creating a web application and a web site? - asp.net

Why does an assembly get created when I am building a web site? I mean a web site and not a web application.

The difference is quite big. A web site is not compiled. Code is placed in the App_Code folder and dynamically compiled by ASP.NET at runtime. A web application is precompiled meaning that you can place code wherever you want and it will produce an assembly at compile-time. You also get a project file .csproj associated with it.
Here's an overview on MSDN.

Related

Why is my ASP.NET site building to a DLL? And what does this mean?

I have built ASP.NET web sites before and usually I start my solution as an ASP.NET Web Site but this time I started it as a Class Library. I then added a web site to the solution. Now when I build my solution I get WebSiteName.dll in bin\.
What does this mean? Is this some compiled instance of my site? Can I use it on my ASP.NET host (arvixe.com)?
Your application is functioning as a web application project now instead of a web site project. Web application projects precompile all of your source code into a DLL, whereas web site projects compile your application on the fly using the code files.
What does this mean? Is this some compiled instance of my site? Can I use it on my ASP.NET host (arvixe.com)?
Yes.
Depending on how it's compiled, you may need more than just that DLL though.
Basically, the web server loads your DLL and the DLL contains your website's code. Depending on how it's compiled, many times you'll need both the DLL and the .aspx pages(and of course images and javascript). But yes, all ASP.Net sites generate a DLL.

Strategies for Hosting 2 .NET Languages in Same Web App

I have 2 web sites (in Visual Studio - separate solutions) - one in VB.NET, one in C#. Ideally, I'd like to make them both web application projects, compile each codebase into to a DLL, drop both DLLs in the bin and drop both sets of .aspx pages under web root folder. So some aspx files would have Language="C#" and some Language="VB.NET", and in the bin you'd have /bin/MyVB6.dll, /bin/MyCSharp.dll. The .aspx pages could be broken up into separate sub-directories. Is this even possible? - Or would they need to be separate virtual directories/web apps in IIS?
Thanks
I see no reason why you can't do that (you can even have one assembly with the help of MSBUild and ILMerge). In a web application the language declaration does not matter and the classes are loaded from the pre-compiled dlls. In a web project each page is compiled at runtime in its own assembly. However you may need to hack your Visual Studio's project files to build the source code in case of web application. To stay safe I suggest you move your code to user controls in separate class library projects.

How do I specify the name of the assembly created when publishing an ASP.NET Web Site Project?

The title pretty much says it all.
Given a web site project in VS2008 named FooDLL, I would like to be able to specify the name of the assembly that VS2008 spits out when I click "Publish Web Site". I am using the "use fixed naming and single page assemblies" option, so the resulting DLL is consistently named.
However, I would much rather be able to specify that the DLL is named something like FooDLL.dll (or just Foo.dll, whatever) than be stuck with the ugliness of App_Web_foo.ascx.cdcab7d2.dll.
Am I stuck since Web Sites don't have .project files (e.g. aren't projects)?
Not to continue the pattern of answering my own questions, but here it is anyway:
All I had to do was add a Web Deployment Project for the web site containing my user control. Though you can't specify the assembly name when building/publishing a web site, you can do this through the web deployment project. It's basically just a nice GUI for an msbuild project file... for a web site. Hooray for hacking a .project file onto a web site!
You could just compile your code as a class library project, then drop it into the Bin directory of your website.
I believe you are.
I am unaware of any benefits to using a web site project and while the benefits of using a web application project are minor, they exist. Create web application projects from now on.
ASP.NET Merge Tool (Aspnet_merge.exe) is your way to go.
It merge your web assemblies into one assembly for the whole Web site.
more information:
http://msdn.microsoft.com/en-us/library/bb397866.aspx

Deploy asp.net application without compiling DLL

When I publish any type of asp.net application, my code is precompiled into various assemblies. I would like to avoid this so that I can upload an aspx page and its corresponding codebehind file. I understand the benefits of doing it either way, but what is desired here is the least risky way to publish changes.
How does one properly deploy an asp.net project without compiling assemblies?
Is the process different for each model (web app, MVC..)
Sounds like you have a Web Application Project, and what you want is a Website Project. With website projects, you can modify the aspx and codebehind files and not have to worry about recompliling them, asp.net will do that for you. Web Application Projects need to be compiled for every code change.

Is dynamic compilation in a 'ASP.NET Web Application' possible?

Can I somehow utilize the App_code folder in a web application project to compile code on the fly? It'd be great for plugins. Recently Rob Conery demonstrated its use in his talk at MIX 09 in a ASP.NET MVC app. I tried to do the same in a web app but I can't access the classes under App_Code from anywhere else. But if Rob was able to do it in an MVC app, it should be doable in a web application too. After all ASP.NET MVC IS a ASP.NET Web Application under the covers.
If you add a code file to the App_Code folder, it should be compiled and available from a code-behind file for a control, or another code file in the App_Code file.
I don't think you'll be able to access it directly from a compiled assembly, since the compiler won't be able to find that reference at compile time.
You'll also need to be aware that App_Code is compiled into a different assembly than your code-behind code, so you can't access internal code across the different assemblies.

Resources