What’s the benefits of Asp.net MVC projects precompilation? - c#

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.

Related

Performance diagnostics of an ASP .NET MVC 5 website

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.

VS2015 MVC No compile experience

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.

Running MVC and Umbraco 4.7 applications in parallel

We are using Umbraco 4.7.1 and it's very slow sometimes, taking more than 10-14 secs to load certain web pages.
Is it possible to create a new MVC web application and use this to display the slow pages instead of Umbraco? The important thing is that it should run on same web server and should replace a specific path currently existing in Umbraco, e.g. http://127.0.0.1/Product.
Any suggestions how to improve the performance are also welcome.
There are two parts to the answer. Firstly, yes you can. You can host the MVC application as an application within the site in IIS. You will need to ensure that you override all the web.config settings as these settings will be inherited. You will also need to add an the path of your MVC application to the umbracoReservedUrls and/or umbracoReservedPaths appSetting in the Umbraco web.config.
However, the second part of the answer is: don't.
Do not create and host a separate MVC application purely because you have performance issues in your Umbraco application. Figure out what is causing the performance issues and fix it. It sounds like you are possibly making too many calls to the database, or the calls that you are making aren't optimized.
My advise would be to run SQL profiler over the site on these pages and check what is happening. You should then review the indexes on the non-umbraco elements of your database, using views where appropriate, and also review whether you are using appropriate caching.

No Compilation Needed - Compile On Run

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.

ASP.NET MVC vs WebForms for First Page Load Speed for Big Projects

We have a pretty big ASP.NET WebForm (web application) project with a lot of references to other libraries, other projects etc and most of the time after a compilation, the first time we load a page it takes a LONG time before rendering anything... Disk IO is the main problem. For small projects it's nearly instantaneous, but once your project gets large, it can really slow development and remove fun from programming.
My question:
Is first page load time after a compilation as long in ASP.NET MVC as it is in ASP.NET Webforms for big projects?
MVC still uses the same ASP.NET framework as Web Forms, so you are probably going to see similar behavior, regardless.
The long first load time is because your project's build output is still just IL code that needs to be compiled into native code by the JIT compiler before executing. Any code changes that you make will cause the previously cached native code for your app to be discarded, so the JIT has to recompile. Naturally, the larger your project, the longer it's going to take for the JIT to process it.
You will see similar load times in both environments.
In both environments, if your site gets large you should pre-compile your site before deployment. This will eliminate the performance drag on first page load.
There are a lot of things thhat can be done to improve performance, the enhancements in order to provide for a separation of concerns in MVC apps can help a lot. Though the default view engine re-uses webforms, Views have a far simpler control stack than typical webforms, which helps a lot, not to even mention alternative view engines.
the hit for 'first view' comes from having to JIT a large set of classes/objects that are used in your project and it's first page.

Categories

Resources