Something weird that I've been seeing, a web application written in ASP.Net (C#) that got the source code on the production server and compile that way. So when I deploy to the server I deploy the source code.
Why does .Net have this functionality? Doesn't make sense.
I have already posted as a comment that I believe that this is a "Web Site" project and not a "Web Application" project, but I wanted to also add this link, which includes some nice links to comparisons of the two project types.
http://www.codersbarn.com/post/2008/06/ASPNET-Web-Site-versus-Web-Application-Project.aspx
This is the way ASP.Net Web Sites work.
Notice that it's very similar to ASP classic, which ASP.Net superseded.
You can also deploy pre-compiled sites, if you want to.
Faster debugging cycle is my guess. For very large projects compiling everything takes time. If you're not interested in bleeding-edge performance (ie debugging a page or 2 over and over and over and over), you can choose not to recompile every time you make an adjustement.
Related
My ASP.NET MVC project is taking more time than usual on the first hit,and it gets better afterwards, but the response goes slow again every next day. so It's a continuous performance issue
I googled the issue and most of the solutions are choosing precompilation during publishing, but Microsoft officials seemly didn’t confirm the operation can result in fast startup time for every request at any time.
So what exactly are the benefits of ASP.NET MVC Precompilation? Please advise
You can basically find the information here, there is also a fair amount of other relevant information on the advantages
ASP.NET Web Site Project Precompilation Overview
Precompiling an ASP.NET Web site project provides the following
advantages:
> Faster initial response time for users, because pages and code files
do not have to be compiled the first time that they are requested.
This is especially useful on large sites that are frequently updated.
A means to identify compile-time bugs before users see a site. (You
can also accomplish this when you compile a project in Visual Studio.)
The ability to create a compiled version of the site that can be
deployed to a production server without source code. This makes sure
that that people who have access to the production server will not be
able to view the source code.
You can also find similar questions here
What is the advantage of the ASP.NET precompilation?
What effect does the new precompile during publishing option have on MVC4 applications?
And some related information here
Precompiling Your Website (C#)
Because the pages must be automatically compiled when they are first
visited, there can be a short but noticeable delay when an ASP.NET
page is requested for the first time after being deployed.
I have an ASP .NET MVC 5 website which runs perfectly on my local machine, but after publishing it to a hosting provider response time from the server is always about 30 seconds (on localhost it is about 100-500ms depending on a page). And I am not talking about first response after some timeout, I am talking about every response, even to pages like "Hello world" with a very simple ViewModel and maybe a couple of strings in ViewBag. At the same time, the static content (like .css and .js files) are returned quickly. I have performed several optimizations, such as:
Installed Razor Generator and compiled all .cshtml files
Got rid of dynamic variables and ViewBags
Made sure that I'm using "release" configuration
Unfortunately, my hosting provider doesn't allow me to configure IIS Application pool, so I couldn't optimize Idle Timeout etc.
Sometimes (very rarely) response time becomes normal (about 200-500ms) but this is for a very short period of time. I've tried several hosting providers and the issue is still there, so it seems to me that there are performance problems with my website but unfortunately I cannot locate and fix them. I'm using shared hosting, by the way, not VDS. So, the question is: Are there any standard diagnostic procedures intended locate and fix performance problems with ASP .NET MVC websites?
After several times of trying to find out solution for the issue with bad performance, I tried to deploy one of Visual Studio's included MVC projects (like #mjwills advised) and it didn't have any performance issues so I was pretty sure that there were problems with my project, not hosting provider. So, the solution for me was to create a new project from scratch and move all code from previous one to the new project, also deleting all the junk code and unnecessary nuget packages. I think that problems were caused either by bad entity framework configuration or by problems with nuget packages installed.
It was my understanding that with the new compiler it is possible to run code without restarting an ASP.NET MVC project, e.g. the no-compile experience.
For example changing the model or controller requires restarting the entire project, which can take quite some time in VS2013 (especially with Code First).
Is this, basically edit&continue for ASP.NET, now possible in VS2015? I tried CTP5 but could not get this working.
Edit: The actual question
Does VS2015, or will it, support edit and continue or a similar experience (not having to restart for model/controller changes) for ASP.NET MVC?
Does VS2015, or will it, support edit and continue or a similar experience (not having to restart for model/controller changes) for ASP.NET MVC?
Visual Studio Edit and Continue is available and works for ASP.Net all the way back to version 2010 with constraints (IIS Express etc...).
Is this, basically edit&continue for ASP.NET
No. Scott Hanselman did a very detailed explanation of all the new features in vNext in this blog post Introducing ASP.NET vNext.
Excerpt:
One of the great aspects of environments like node or rails is that they are "no compile." Just change some code and hit refresh. With the next version of ASP.NET you get the power and throughput of the .NET runtime plus the "Roslyn" compiler-as-a-service for a "no-compile compile." That means means during development time you can just change your C# classes and hit Refresh in the browser. It's the power of .NET with the dynamism of a refresh-and-go development experience.
and
NOTE: This isn't ASP.NET Websites, or Razor View compilation - this is the whole thing, compiled in memory. You can use Visual Studio for development, or text editors like Sublime, or freakin' Notepad. (Of course, if you want assemblies on disk, you can do that too.)
and
See my web app’s bin folder in the screenshot below? There’s no assemblies in there because the assemblies never exist on the disk. It’s actually faster and easier to have the compiler do all the work in memory.
I'm in a situation that I do not know how and I do not know if it's possible to do.
I have a website in ASP.NET MVC, let's call kelvinsite.com.br, this site is a asp.net mvc project.
And I also have another site, we'll call kelvinproject.com.br, this site is another project aspnet mvc.
What I want to do is publish the site kelvinproject.com.br inside the project kelvinsite.com.br without merging the web projects in the same project in Visual Studio, I want both to stay separate in the same solution.
So the url would be:
http://kelvinsite.com.br/kelvinproject
Is it possible? What is the name of it?
It's possible, but there's some potential pitfalls depending on how you've defined your URLs. The term you're looking for is "sub site" and it usually requires some work in IIS. You could do something similar with ASP.NET MVC Areas, but you're not really packaging the apps separately in that case.
There's a pretty good discussion on subsites here: Sub-Website in IIS - ASP.NET
Basically, you deploy the app to a subfolder of the parent app on IIS. Configurations get carried down, which means you might have to change the web.config on the child to remove parent entries, etc, depending on things like .NET versions of each, etc.
You should be able to publish each site completely independently. There are only two major things to keep in mind on the server.
1) Make sure that the directory, kelvinproject, is marked as an application in IIS.
2) You may need to adjust the web.config in the main application so that it's settings aren't inherited by any child applications. You can easily do this using the element of the web.config. There's a good example of this at: Scott Hansleman's blog and it's pretty simple. Just put things like and within this location and it won't be inherited in the new application.
Don't think of them as a specific site. Each one is a sepeaate web application and technically they don't know anything about each other, and don't care about the other. You can have 50 projects in the same solution and it doesn't matter to any of them where the others are published.
I'm inheriting a web application and the previous programmer compiled all his code into a .dll. The .cs files are not present on the server.
Working on previous projects, I've always uploaded the .aspx file and the corresponding .cs file. It's never been a problem for me and I always thought it was standard procedure. Am I wrong or just paranoid?
Will,I think this is quite common to keep code precompiled into dll. Then the code is less exposed for potential security holes. This provides also many advantages, which include faster initial response time, error checking, source-code protection, and efficient deployment. This is particularly important in large sites where there are frequent changes in Web pages and code files.
Leaving source code as a part of the project isn't necessarily the best source code management process. There are tools for that.
Also, precompiling source code isn't out of the ordinary (this is a Web Application project rather than a Web Site project in Visual Studio), and has many benefits.
Note that this doesn't make you wrong or paranoid.
There are good reasons for both strategies you just have to figure out what is going to work best for you environment and for the application.
In some ways it is good to have it precompiled if you worry about someone accidently making a change on the server but not checking the change into source control. With non-precompiled if you don't have change control on your server it can be hard to figure out who "accidently" made a change and why without checking it in.
On the other side, if you don't precompile it can make deployment more straight forward.
Just do a little research behind both strategies and decide what is going to work best in your situation.
As Nader pointed out, in a Web Application you don't need the CS files at all. There is not a huge risk of the source files being served accidentally, as protecting these files is a core function of IIS request management. Still, it is generally good practice not to deploy them to a production web server.
In any case, source files should at the bare minimum always be backed up in a location that is not the web server and should be source controlled whenever possible. I have seen too many websites where the source files were lost and the site was useless as a result.
Like everyone above has said, compiling source code into DLLs is considered best practice.
If you'd like to see the code of the DLLs you've been left with, there's a handy (and free!) tool called Reflector (apologies if you've already got it)
http://www.red-gate.com/products/reflector/
Just load up the DLL and then disassemble to view the source.
Web Application Projects compile into .dlls and leave no source on the server.
Web Site Projects deploy all the source to the server.
It's a religious war as to which is best. Google will present you with many varied opinions, so I won't press my own opinions on you.