I migrated my existing app over to .NET Core 2 (it was such a pain...), but it looks like everything is working now. However, I noticed that initial load up of the webApp and logging out is very slow. I think in these two scenarios, a .cshtml is being rendered by the server.
I took out applicationInsights which made it a bit snappier, but loading is still slow. I also tried not using kestrel to load my https cert and to just have it be http. That seems to be quicker as well, but I need https to be configured.
Are there any solutions to this? Microsoft documents doesn't seem to have an migration tips on the cshtml files themselves.
EDIT:
I also found this thread: Visual Studio debugging/loading very slow
Not sure how to turn off symbols in VS Code though. Or if that is a related issue.
EDIT2:
I found this in the docs:
Razor view precompilation is currently unavailable when performing a self-contained deployment (SCD) in ASP.NET Core 2.0. The feature will be available for SCDs when 2.1 releases.
Could that be the reason why my view is slow? Is it rendering/loading each time?
EDIT3:
Index.cshtml:
`
@{
ViewData["Title"] = "MyTitle";
}
<div id="react-app">
<svg
class="svg-loader"
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 50 50"
style="width:60px;height:60px;display:block;margin:100px auto">
<path d="">
<animateTransform
attributeType="xml"
attributeName="transform"
type="rotate"
from="0 25 25"
to="360 25 25"
dur="0.6s"
repeatCount="indefinite"
/>
</path>
</svg>
</div>
@section scripts {
@if (ViewData["jwt"]!=null)
{
<script>
var token = '@(ViewData["jwt"].ToString())';
localStorage.setItem("jwt", token);
</script>
}
<script src="~/dist/app.js" asp-append-version="true"></script>
@if (ViewData["appInsightKey"]!=null)
{
<script>
var appInsights=window.appInsights||function(config){
function i(config){t[config]=function(){var i=arguments;t.queue.push(function(){t[config].apply(t,i)})}}var t={config:config},u=document,e=window,o="script",s="AuthenticatedUserContext",h="start",c="stop",l="Track",a=l+"Event",v=l+"Page",y=u.createElement(o),r,f;y.src=config.url||"https://az416426.vo.msecnd.net/scripts/a/ai.0.js";u.getElementsByTagName(o)[0].parentNode.appendChild(y);try{t.cookie=u.cookie}catch(p){}for(t.queue=[],t.version="1.0",r=["Event","Exception","Metric","PageView","Trace","Dependency"];r.length;)i("track"+r.pop());return i("set"+s),i("clear"+s),i(h+a),i(c+a),i(h+v),i(c+v),i("flush"),config.disableExceptionTracking||(r="onerror",i("_"+r),f=e[r],e[r]=function(config,i,u,e,o){var s=f&&f(config,i,u,e,o);return s!==!0&&t["_"+r](config,i,u,e,o),s}),t
}({
instrumentationKey: '@(ViewData["appInsightKey"].ToString())'
});
window.appInsights=appInsights;
appInsights.trackPageView();
</script>
}
}
`
EDIT4:
I narrowed it down to layout.cshtml: The renderBody and section seems to be really slow. I'm going to read up more on it.
`
@RenderBody()
<script src="~/dist/vendor.js" asp-append-version="true"></script>
@RenderSection("scripts", required: false)
</body>
`
EDIT:
<script src="~/dist/app.js" asp-append-version="true"></script>
It looks like this line is the reason why its slow.
The pages that they are loading have not changed and are the same size. Yet in 1.1 it takes around 8seconds and in 2 it takes 35 seconds. The 1.1 load time wasn't great to begin with, but in 2 its ridiculous.