mvc asp.net web project first load - asp.net-mvc

I published My Web project that written by C# MVC5 ASP.NET and Entity framework on a Shared Host. First Time that it loads, speed is very slow and take a long time almost 12 second but after that it is ok . I tested my website on a gtmetrix.com and fortunately is in A class.Could anyone tell me why it takes a long time for first load ?I have some suggestion.
1)it because of entity framework ?
2)it because of a lot of library that I used them and it needs to load these dll files before load ?
3)I need some config in IIs (I dont access to IIs Server because Im using shared host)?
(also compilation debug is false)
I am appreciated If some one help me .
web site address is www.kajalmarket.com and is uploaded most recently .

You can precompile prior to deployment if you're concerned.
Here's more info:
https://msdn.microsoft.com/en-us/library/ms227972(v=vs.90).aspx
Precompiling an ASP.NET Web site provides faster initial response time for users since pages do not have to be compiled the first time they are requested. This is particularly useful for large Web sites that are updated frequently.
You can also select "Precompile during publishing" if you publish via Visual Studio:
Click here to see screenshot.
Another option is as follows taken from ( https://msdn.microsoft.com/en-us/library/ms366723.aspx ):
If you want to be able to change top-level files without causing the whole site to be recompiled, you can set the optimizeCompilations attribute of the compilation element in the Web.config file to true. If optimizeCompilations is true, when you change a top-level file only the affected files are recompiled. This saves time but can cause run-time errors depending on the type of changes you make to a top-level file.
With this method you should see a reduced re-compilation time as it only recompiles those top level files that have changed.
HTH

Related

Dynamic Page Content on Precompiled Azure Web App

I am just about to launch an Azure Web App (aka Azure Web Sites) and have a quick question.
I've noticed there was a pretty significant lag on using the site when I publish my site from Visual Studio. Each page(/controller?) appeared to be compiling only when it was first accessed so it made the site feel very slow at least for a few minutes. I want to avoid that so I am used the "Precompile" option when I Build and Publish from VS. This seems to work and, although there is still some initial lag after publishing, it's much better than it was.
My question is this: Because this is a new site and we are constantly adding functionality and fixing bugs, I would like to have a section on my main _Layout page which I can quickly edit with a notification (ie. "Site will go down in 15 minutes for maintenance."). The problem is that I don't want to go through the whole Build/Publish process to get that content up to the site. Is there a way that I can include some file / content (page_alert.html) in my _Layout.cshtml page that can be edited in something like the Azure App Service Editor? Because of the precompiled nature of the site, all my .cshtml files now just say "This is a marker file generated by the precompilation tool, and should not be deleted!" in the App Service Editor.
Thanks!
When you choose the Precompile option, you can also check 'Allow precompiled site to be updatable'. That will then allow you to update individual .cshtml files which will be compiled on the fly, while the rest is still precompiled.
See doc for details.
I think I found a solution that will work from another SO posting.
https://stackoverflow.com/a/14634578/1359788
#Html.Raw(File.ReadAllText(Server.MapPath("~/content/somefile.html")))
I can edit that somefile.html in the App Service Editor and it works

Precompile during publish for Azure Web Services

We are using Azure Web Services (not Web-sites) and run ASP.Net MVC 5.1 application inside it.
When I publish web-sites through Web-deploy, I have an option to "Precompile during publishing":
When I publish to Azure Web Services, I can't find this option anywhere. Any pointers?
The idea is to pre-compile views, so first hit to a view would not be time-penalised by compiling on the fly.
I've looked on Razor Generator but it does not suit our needs. I've seen few other options, but compiling views at publishing stage makes the most sense for our case.
UPD:
Just for my reference, I've tried what David Ebbo suggested and it did not work.
Calling compiler %windir%\Microsoft.NET\Framework64\v4.0.30319\aspnet_compiler.exe -m /LM/W3SVC/1273337584/ROOT from command line on the Azure server seems to cause compilation. The Temporary ASP.Net root directory contains one directory this increases in-size and number of files contained within. The site then restarts after compilation. First page open performance then seems much better.
If I run this within a startup script it doesn't work as the site isn't avaible. I guess IIS hasn't started up. Looking at doing something like this Azure: How to execute a startup task delayed?
The site ID doesn't seem to change for different deployments. I guess could get the site id out of IIS and then use that it if it does.
So looks like that does it. Is there are more elegant way? Don't understand why compiling and deploying view files is such a chore.

download source code, but not working

I had a problem with part 3 of an orchard tutorial...
so I was attempting to download the source code for part 4 and continue on from there (which can be found about 3/4 of the way down at the end of the tutorial on the page http://skywalkersoftwaredevelopment.net/blog/writing-an-orchard-webshop-module-from-scratch-part-4
However when I run part 4 from webmatrix I get the error(see below)
im guessing this is because iv only downloaded the code but i need to put it inside a seperate project? is this correct? can someone advise me how to do this?
thanks for any replies
The error states that there is no default document configured in IIS. Attempt to access the document using the full URL.
For instance http://localhost:28266/default.aspx (or similar)
You can then adjust IIS to have the correct default document (if desired)
Edit: After reviewing the referenced ZIP archive.
This looks like a changed file zip for the application. This isn't a complete ASP.NET MVC application by itself and, as such, isn't viewable stand alone. I don't have the time to parse the exact steps required to make this application work alongside the demos provided, but be sure you're either combining all of the previous files and folders in order or follow the instructions detailed by the author.
As referenced, this is not a complete ASP.NET MVC application and isn't ready to be immediately rendered by IIS.
The problem is probably that the application can't start for some reason, which causes IIS to attempt to respond to the request with other handlers. Because there is no default document defined (and there shouldn't), it tries to do a directory listing, which is not allowed in your configuration. Do not focus on what IIS is telling you but rather on why your application doesn't run.
Things to check:
you have built the application
you are running in full trust
you are running in integrated mode
there is no exception in app_data/logs
you added the module to a working Orchard instance, in its Modules directory

How to deploy Umbraco 5 website

I hope I'm asking this question in the right place. I also asked on umbraco forum, but did not get any response yet.
I'm having problem with deploying my Umbraco 5 website to external hosting.
On local machine, I used Umbraco 5 template for VS2010, which works fine (although it's quite slow).
When I publish to live server I get 500 error.
So far, i've tried installing fresh copy of umbraco on hosting (works fine).
I copied config files in hive provider folder (in App_Data), to point umbraco to my hosting database. That does not throw any exceptions yet. Problem starts when I copy views and partial views over - umbraco then finds the template defined in database and tries to load that.
It's worth mentioning that I also copied my project.dll file into bin directory on the server - the reason for that is because I have added new controller which inherits from surfacecontroller (in /Controllers folder).
Please let me know if I'm doing something wrong.
Cheers
Sebastian
It is not any different than deploying a MVC3 website.
There are quite a few questions with exactly that signature here on so.
Visual studio even has a few tools to help you in the process.
The publish function is found right clicking the project in the solution explorer.
If you use the template for developing, you have a working umbraco solution locally right?
If that is the case, it is easier to just deploy / publish the entire site intead of copying bits into another umbraco solution.
Publish tool
When using that tool, remember that umbraco has quite a few config files etc. and they all need to be included. So it is probably the easiest to just export all files in the folders, by changing "which files to include" setting in publish tool. That will unfortunately include all your .cs files too, but later they can be filtered out of the publish process.
First make it work, then make it awesome :)
The same goes for compilation mode, i have found that release mode sometimes breaks things, so for now just keep it in debug mode.
Then later when you have it working, you can change to release mode for a small performance gain.
Stuff to remember
include all necessary files
change connectionstrings
copy databases
custom errors, you don't want your visitors to see YSOD's with your internal debugging info.
disable tracing and debugging!
After reading this, you should go on and look for other more elaborative resources too.
"umbraco then finds the template defined in database and tries to load that" is key point to me
whatever the version you follow the templates and doc types are the backbones of umbraco ( from you website I know that you are aware with above more then me.. but repeating.) I mean you have created new website but there are no relative Templates and Doctype yet you try to use them in views and subviews and that caused the problem.
To do that please create tempalte and doctype same as is in you staging site and this problem will be solved.
Even better kick-start you development with new site only and make replica of that after defining doc-type and templates to your staging.
I hope i can explain my point.
Thanks,
Jigar
I've had problems in the past deploying Umbraco 5 projects. When you deploy an Umbraco 5 website to a new server and before you switch the website on in IIS, navigate to \App_Data\ClientDependency and delete any XML files that are there. Next, navigate to \App_Data\Umbraco\HiveConfig and delete the ConfigurationCache-*.bin files.
Once you've done that, recycle your Application Pool and start your website.

ASP MVC 2 with asp.net development server won't load default controller & action for an empty route

This used to work fine, but recently it refuse to load the default page for an empty route, instead it lists directory contents.
for example
http://localhost:1234/ should take me to the same page as http://localhost:1234/Home/Index assuming global.asax hasn't been modified, however recently it just takes me to "Directory List -- /" and lists out the content of the project folder.
This is using the ASP.NET Development Server. The sites work fine when deployed into IIS on a server.
Does anybody have any ideas, this is really annoying!
I would check the project settings like suggested on this other question:
Launching my debug MVC3 application opens a specific .cshtml file in the browser
Through trial and error I've determined that this is caused by the IBM RTC plug-in, when disabled it works normally.
I find this very surprising, but I've double checked and it is definitely that!

Resources