Slow startup with IIS Express

前端 未结 8 971
余生分开走
余生分开走 2020-12-28 13:53

I have a problem with my MVC application and startup.

Every time I make a change and one the app its take a long time to start up.

I have about 100 lines wit

相关标签:
8条回答
  • 2020-12-28 14:01

    You can control it from the Global.asax file by taking advantage of ViewEngines.Engines.Clear().

    protected void Application_Start()
     {
            ViewEngines.Engines.Clear();
            ViewEngines.Engines.Add(new RazorViewEngine());
            AreaRegistration.RegisterAllAreas();
            WebApiConfig.Register(GlobalConfiguration.Configuration);
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);
            AuthConfig.RegisterAuth();
      }
    
    0 讨论(0)
  • 2020-12-28 14:03

    It may help to check the following Debug options:

    Tools > Options > Debugging > General

    • Enable "Enable Just My Code"
    • Disable "Enable .NET Framework Source Stepping"
    • Disable "Source Server Support"
    • Disable "Source Link Support"
    • Disable "Use Managed Compatibility Mode"
    • Disable "Enable Edit And Continue"

    Tools > Options > Debugging > Symbols

    • Disable all Symbol file locations
    • Set Symbol cache directory
    • Select "Load only specified modules"
    • Click "Specify included modules" and disable all
    0 讨论(0)
  • 2020-12-28 14:13

    IIS Express should continue to run in the background while you change and compile your code. You can then go to Debug -> Attach Process and find the iisexpress.exe process and attach to it. The problem with hitting F5 every time is that VS tears down the process and restarts it which takes time.

    0 讨论(0)
  • 2020-12-28 14:14

    I had this same problem, tested with VS2010 and VS2015. Symptom: VS was quick, compiled, loaded symbols and opened browser within a second but then browser just hung for 5 to 20 minutes. My projects are huge but my laptop is 16GB RAM, i7 and SSD so definitely not a size problem. I tried all the answers on this question and also here Visual Studio debugging/loading very slow.

    In the end I found the solution here https://social.msdn.microsoft.com/Forums/en-US/394f3100-bac2-4b1c-8f8c-731226b905d4/painfully-slow-starting-a-web-application-in-visual-studio?forum=visualstudiogeneral

    Exclude the directory "C:\Windows\Microsoft.NET\Framework" from antivirus scanning

    Hopefully this will save someone else so much wasted time :)

    0 讨论(0)
  • 2020-12-28 14:14

    I had the same problem with IIS Express 10, Visual Studio 2015 Update 3 on Windows 10. I did a few tests and with different settings and browsers (Chrome 54, Edge 38, Opera 41). The browser doesn't really matter, but I found three things which significantly changed my original 15 seconds load time:

    1. Switched Windows Defender 4.10 off (changed from 15 to 12 seconds)
    2. Turned Edit and Continue feature off (changed from 12 to 6 seconds)
    3. Switched Windows Defender 4.10 back (changed from 6 to 8 seconds)
    4. Tried to run the application without debugging (changed from 8 to 2 seconds)

    So if you are willing to give up Edit and Continue, or even debugging then you can speed up the process.

    Edit and Continue can be turned off in Visual Studio/Tools/Options/Debugging/General/Enable Edit and Continue.

    You can start your project without debugging with Ctrl+F5.

    I would not recommend to turn off your Windows Defender, but you can play around with its exclude directory function, you might win a few seconds there as well.

    0 讨论(0)
  • 2020-12-28 14:17

    I found significant improvement after disabling logging.

    Locate the IIS config for your project or machine, typically found in:

    • %userprofile%\documents\iisexpress\config\applicationhost.config
    • .\.vs\config\applicationhost.config
    • VS2019: $(solutionDir)\.vs\{projectName}\config\applicationhost.config

    And comment out or delete the following two nodes (found somewhere in the document)

    <add name="HttpLoggingModule" image="%IIS_BIN%\loghttp.dll" />
    <add name="HttpLoggingModule" lockItem="true" />
    
    0 讨论(0)
提交回复
热议问题