I just upgraded my ASP.NET (Framework) MVC app to ASP.NET Core 2.2. That process was painful enough, however even more painful is running the web app locally.
Issues with running in IIS Express:
If I launch the app with F5 (to enable debugging), then once I stop debugging the browser window closes so I have to start over on the homepage each time after changing any code.
If I launch the app with Ctrl + F5 (no debugging), after a few rebuilds the website seems to die, meaning that any new page requests just say host not found. I then have to Ctrl + F5 again to get it going again, but then I'm back on the homepage.
Visual Studio 2019 sometimes decides to launch the webpage in my existing Chrome window on a new tab, but sometimes decides to launch it in an entirely new Chrome window. After several minutes of dev, I'm left with multiple tabs and windows open.
Issues with running in IIS:
The only way it runs is if I manually edit my Web.config to have the proper values for processPath ("dotnet") and arguments ("./bin/Debug/Housters.Web.dll"). Visual Studio likes to inject in aspNetCore processPath="%LAUNCHER_PATH%" arguments="%LAUNCHER_ARGS%" every time I build or run my app, despite me having IsTransformWebConfigDisabled = true in my .csproj. So I constantly have to go into git and revert these changes, or else my app will fall back to the dreaded ANCM In-Process Handler Load Failure page.
Assuming the Web.config has the proper values, after running the application in the browser I can no longer build the project. Instead it gives the error: Error MSB3027 Could not copy "obj\Debug\netcoreapp2.2\Housters.Web.dll" to "bin\Debug\Housters.Web.dll". Exceeded retry count of 10. Failed. The file is locked by: "IIS Worker Process (15496)". IIS is using the ASP.NET Core web app's dll so I can't actually update my code and build it, that's just great. The workaround is to recycle my IIS app pool, but this gets old REAL quick when you need to do it before every single rebuild.
Attaching to the w3wp.exe process isn't causing any breakpoints to be hit, so I can't debug under IIS (IIS Express debugging works fine.)
The launch profiles that I configured in launchSettings.json are ignored. For example, when I choose my IIS launch profile (which has "http://localhost" as the launchUrl and applicationUrl), if I F5 or Ctrl + F5 it opens "http://localhost:62551/" in the browser window.
So this begs the question, how are others developing/running/debugging their ASP.NET Core apps on their local dev machines? Maybe most web developers have moved away from ASP.NET to purely javascript frameworks like Angular, React, and Vue so I'm just out of luck? Or am I missing something that will make ASP.NET Core development less painful?
Currently, the experience with ASP .NET Core has greatly improved compared to the past.
However, certain glitches still remain. For what regards IIS Express (in production we use Kestrel), you can try these things with Visual Studio 2017 and 2019 (they work for us):
If I launch the app with F5 (to enable debugging), then once I stop debugging the browser window closes so I have to start over on the homepage each time after changing any code.
Just don't use the page: let the tab/page open, spawn another tab/page and use the latter for debugging. This way your session is going to be as similar to a production environment. We have Firefox as default browser, but we usually debug with Chrome, therefore, not touching the process spawned by Visual Studio keeps IIS Express alive.
If I launch the app with Ctrl + F5 (no debugging), after a few rebuilds the website seems to die, meaning that any new page requests just say host not found. I then have to Ctrl + F5 again to get it going again, but then I'm back on the homepage.
It seems that cleaning the whole solution twice solves the issue (at least for us). The first time you clean the solution, IIS Express still serves the site. Apparently, this should be the designed way (cannot find the documentation about that).
If that does not work, it might happen that a Visual Studio service is stuck. In this case, shut down Visual Studio (I know, it's painful), wait a little bit, and kill all the dotnet.exe currently running after verifying they are part of Visual Studio.
Visual Studio 2019 sometimes decides to launch the webpage in my existing Chrome window on a new tab, but sometimes decides to launch it in an entirely new Chrome window. After several minutes of dev, I'm left with multiple tabs and windows open.
This is partially what I said previously. Although painful and resource expensive, having multiple windows open allows us to survive.
For reference, we use the very same configuration on debug and release (with kestrel).
Related
It seems like the View in Browser option doesn't really require IIS and it seems to process ASP pages fine. So how does it really work without a web server?
They used to have a developer web server (Cassini) which is dead long time back so is there some kind of built in capability in visual studio? Who processes the requests by asp pages if it doesn't require IIS?
I already have IIS installed so I am not sure if is servicing the pages but seems like it will work without IIS because I don't configure anything in IIS and new ASP.NET projects work out of the box as well View in Browser option for an asp page option which just directly executes that page.
Actually this is what occurs:
Your web web.config is copied.
Then VS spools up a WHOLE running copy of IIS (it is the express version - but it is the same for the most part as the full edition of II).
Once VS spools up and starts and configures that running copy of IIS?
Then your web page and web application can run. If you look at your system try, you see this:
So in above that 2nd from the left in the tray shows that blue thing icon. I have right clicked on it to show the options you see.
So now you have a running copy of IIS on your computer. So you ARE running a full web server here. (well, ok IIS express - but the base parts and what that means is much the same as the full edition).
Around about VS version 2010, they USED to have a smaller built in web server as part of VS. The problem of course was for Microsoft to maintain 100% compatibility was VERY hard. So while for a considerable time frame and history of VS? Yes, they had a built in web server as part of VS. But they dropped it a number of versions ago in VS, and as noted now use IIS express.
So Now? Well, when you install VS, they also install a working copy of IIS. (the express version). The express version is quite much the same as the full pop edition of IIS. What is removed is "most" if not "all" of the IIS management screens and setup. (and sometimes I wish they would just install that part too!).
Your experience thus that a copy of IIS is launched. Once launched IIS does keep running during your development process (depends on your VS config and setup). But, if you go file->close solution, then you find that IIS express then also shuts down.
So, to view that web page? Yes, VS does config, and then does spool up and start internet services and that web server. So this running of IIS on your computer is what allows those web pages to work and run correctly. As noted, while this is a copy of IIS, it is for the most part the same as the full edition - just with most of the management tools removed. As noted, you SHOULD see that new icon appear in the system tray.
And as noted, I believe around VS 2010, they made that switch from the VS built in IIS to that of now using IIS express edition. As noted, this change was made to ensure a greater probability that when coding and debugging your web site in VS, that the end result will be much the same when running a full edition.
I do find that over time, the production (web hosted site) does get so many config and tweaks and changes, that I now can't include my web.config file in the publish (can't risk overwriting the server production web.config). So, over time, we added things like https security certificates and installed them, and set them up for the production web site. I don't have those same security certificates setup on my local machine. And of course there are some virtual folders and few more things that exist on the production web site as opposed to the dev copy I use. So, it somewhat my fault to let the production web.config over time to become "different" then what I run local when coding and debugging the web site. So now, when I publish - I remove the web.config file before I actually copy the new updated web application to the final production server (which of course is running the full edition of IIS).
But to make a long story short?
Yes, a whole copy of IIS web server is configured for you, and that whole copy of IIS is spooled up, launched, and once that occurs, then your web page option "view in browser" can run. But make no mistake here - IIS services is setup, is started, and is running for that web page preview to occur.
I have a website in IIS and if I open it in Visual Studio (running as admin) the application pool always restarts - which is a big problem on my live server. Can anyone help me prevent it from happening?
I realise precompiled web applications exist and that RDPing to live server and using VS like that is not ideal but I can't change that right now.
My project is a VB website (no MVC - just .aspx pages) and I use Roslyn and all the new language features so I can't remove DotNetCompilerPlatform (I don't think choice of language or the code has anything to do with the problem). This happens on Windows 10 and Server 2016.
From my investigation I found the following:
It seems VS does SetSecurityFile on every file in /roslyn directory which triggers a NotifyChangeDirectory message. The permissions on the files remain the same - VS updates them for no apparent reason and that rightfully causes a recompile of the website.
I've cleaned out the NuGet package DotNetCompilerPlatform. I've tried applying loose permissions on the project directory (Everyone - Full Control). I've tried VS 2017, 2019 and the new 2019 preview. Nothing helped so far. What I do know is that this didn't used to happen in the past.
Any ideas would be appreciated.
The application pool will not automatically restart unless you set the recycling time or an error occurs, So please check if there are related errors in your Event Viewer. and try to change the startMode of your application pool to AlwaysRunning:
Open Internet Information Services (IIS) Manager.
In the Connections pane, select the Application Pools node, revealing the Application Pools pane in the main view.
Click Advanced Settingsā¦
Locate the Start Mode option under the General group and set it to AlwaysRunning.
I have a web project (DNN module) that I am developing and I recently updated to Visual Studio Professional 2015 Update 3.
I am using IIS 10 on a windows 10 PC
When I try to F5 / Debug my app I get the following warning on any breakpoints:
the breakpoint will not currently be hit. no symbols have been loaded
for this document
What I have tried to fix this:
I enabled directory browsing inside IIS 10
I Run VS in admin mode / elevated permission
Updated MS ASP.NET and Web Tools extension to latest version
Updated MS ASP.NET Web Framework and tool extension to latest version
cleared out and re-downloaded all debug symbols
Clean and rebuilt in both release and debug mode
Made sure modules runAllManagedModulesForAllRequests="true" is set in
system.webserver of web.config
Restart IIS / refresh application pools, and restart website
using a different port for the website
obviously restart computer / and visual studio
I am at a total loss and really need help. I can not figure out why my breakpoints are not being hit, when I debug the site no errors are thrown and the site runs fine.
Other Attempts:
From this SO thread I tried:
Install Update for Microsoft Visual Studio 2015 Update 3 (KB3165756)
From This SO Thread I tried:
disable "just my code" in debug general settings
From User suggestions:
I have tried attaching directly to the w3wp.exe process - no breakpoints hit and visual studio crashes when I try to stop debugging. Also, as soon as I attach the debugger, the website stop workings all together
Question
Can someone help me figure out why my break points are not being hit when debugging from visual studio.
EDIT # 1: Additional attempts
When I debug my application and open the Debug -> Windows -> Modules window I do not see the name of my projects dll / pdb file in the list of Modules. I tried going to Debug -> Options -> Symbols and clicking the Load All Symbols button.
I included a screen shot. My dll or project is named krisisShifts so the dll created in the obj/Debug folder is krisisShifts.dll and KrisisShifts.pdb etc. The blue mark on the image shows the dll is not listed in the loaded modules. Also I included the default attached process Visual studio is using to debug the site marked in Red.
I also deleted the site and application pool from IIS and recreated them with different names, site displays fine, but no breakpoints hit
EDIT 2: Attach to process now works
Not sure what I did. I have been fighting with this all day and afer restarting the computer and visual studio numerous times I can now attach to process w3wp.exe and the breakpoints are hit.
However hitting F5 still does not work. The site loads but no breakpoints are hit and I can see that my projects .dll is not added to the debug modules list (but it is when I attach to process).
I feel like I am closer but still can not figure out why my project .dll is not loaded in the debug modules when hitting f5.
Are you able to attach directly to the w3wp.exe process, and if so are your breakpoints hit then?
Menu > Debug > "Attach to process..."
Check "Show processes from all users"
Look for a process named "w3wp.exe", with the username "IIS APPPOOL\{IIS site name}"
Click "Attach"
When I try to debug my VS2010 web app (F5), the IE web browser windows pops up but then freezes, and my VS2010 IDE window pops up an error message:
Unable to start program 'http://localhost:nnnn/Login.aspx'.
Access is denied.
I'm running VS2010 (10.0.30319.1), targeted to ASP.NET 4.0 (4.0.30319), in non-administrator mode, with ASP.NET debugging enabled, on 64-bit Windows 7 Enterprise SP1, with IE 9 (9.0.8112.16421 with update 9.0.29).
This web app and others I work with have been working just fine for several months, but they all started to misbehave in this manner a few weeks ago. At first, the first time I tried to debug (F5) I'd get the error, but after clearing it and closing the IE window and trying F5 again a second time, the browser would come up just fine. I assumed it was just some glitch, so I tolerated it.
Lately, though it has gotten worse, to the point that 90% of my attempts and re-attempts to debug the web app cause a hung browser and the error. It sometimes works, but most times it doesn't. I have to kill the handing iexplorer.exe processes to clean up my user space, otherwise I eventually get a message about not having enough files to start the browser. I try rebuilding, stopping the ASP.NET Development Server process, even exiting VS2010 and restarting it, but I can't seem to find the magic sequence of events to get it to work.
If I start without debug (Shift-F5), it works, but two IE web browser windows are opened, and both attach to the web app. I don't know if this is related to the first problem. And needless to say, this does not really allow me to debug my code. I tried attaching to either of the IE processes, but I still could not get the debugger to actually debug the executing app. (There is a message about no symbols being loaded for the attached process.)
Most of the solutions for this problem I've found say something about running with administrator access. I cannot do this, however; I work at a large financial company, and developers are not allowed to have local admin rights on our PCs. I don't control system patches, but I can request Help Desk ticket to resolve the problem; but I'd like to resolve this problem myself if it is a fairly simple configuration problem on my part.
Addendum
I should also add that I am not using IIS (because I don't have it installed on my system, and I can't use it anyway because I don't have local admin rights), but instead I am using the built-in Visual Studio Development Server. I've also selected a specific HTTP port number for it to use. Also, all of the directories I'm been using were created by me (as part of my project workspace), so there should be no access permission problems.
Like I said, I can sometimes get a debugging web session started, but most of the time I can't. So whatever is causing this problem, it is probably something intermittent.
This tend to occur when you try to run the full version of IIS rather than the Visual Studio Web Server or IIS Express. Have you tried running IIS Express instead? I think there's support for IIS Express that came with one of the later updates to VS 2010?
IIS proper definitely requires full admin rights in order to attach a debugger because full IIS runs under a system account rather than your own account. IIS Express (as well as the Visual Studio Web Server) however should run under your own user account and so debugging should work on the local machine even with a non-admin account.
One issue that might cause problems is directory permissions. Make sure that the folder where your Web files live are read/execute accessible through the file system for your user account.
Finally make sure you don't have some other instance of a Web service running on the same HTTP port.
I am having the same issue, it works when i don't choose to debug but CTRL+F5 to start it. F5 Debugger al
Why are the code-behind pages for an ASP.NET web application locked at run time? I have older projects (probably defined as "web sites" instead of "web apps") where I can edit the code behind, refresh the browser, and see my changes. With the web app, I have to continually close and reopen the browser if I want to see my changes live. Is there a setting or something I'm missing to allow me to edit at run time, and without restarting the debugging session?
You can enable Edit and Continue in the project properties. Right click the project in the solution explorer, select the Web tab and check Enable Edit and Continue.
Now you can edit your sources, but you have to pause the debugger to do so.
When using IIS as your development server, Edit and continue is not currently available for Visual Studio for ASP.NET.
See this blog entry, however, that shows it is possible for the Visual Studio 2005 Web Application Project Project type. It requires using the Visual Studio Development Server (Cassini) during development instead of your local IIS (see the properties box on the project).
No, in web applications, the codebehinds are pre-compiled into dlls, so any change in the dlls will recycle the App pool, and stop your debugging session,
If you press ctrl-F5 instead of just F5 to start (or host you site in IIS), you start without the debugger, and don't need to restart the browser all the time...
Unless you really really need to debug a problem you can't figure out, You should start the web app without debugger, makes it snappier to start up. Every minute spent debugging is a minute not spent writing a unit test. IMHO you should write unit tests, they last longer.