ASP.NET MVC Debugging, updated libraries not used by IIS Express - asp.net-mvc

ASP.NET MVC, Visual Studio 2010, C#/.NET4. I'm using IIS Express as the web server of choice, as it more accurately mirrors our production configurations in IIS7. However, when I go through following process, the libraries used by IIS Express don't seem to be updating.
Run app, find bug
Stop VS2010, fix bug
Build/Run
Testing reveals the new code is not being used
IIS Express continues to run even after stopping the debugger in VS2010, so I'm assuming it's just holding onto the binaries that were used when it was initially launched. Is there a way to get it to use the updated binaries? Or is this the expected behavior? Right now, the only way I can get the new binaries used is to completely exit VS2010 and then reload the project/solution. Even selecting "stop" from the IISExpress systray icon doesn't seem to actually help (it doesn't appear to actually stop the process).
Obviously closing VS2010 and reloading the solution each time is a less-than-ideal workflow.
EDIT: The project is configured to run IIS Express from right click project -> Web. The project URL does not use any virtual directories, it is at root of the local host on port 60830. I thought I remembered seeing IIS Express in the F4 properties listing before, it's not listed there at all right now.

Related

Apply changes without restarting project visual studio for mac

I am using Visual Studio for Mac to develop net core MVC, and I'm struggling with restarting the project after I made the changes on controllers or models.
For comparison, asp.net in windows. I just need to register the project folder to IIS and I can access it trough browser with "localhost/myproject". And when I do the changes on backend and rebuild, it directly apply the changes.
Is there any way that I can duplicate the way windows does in mac?
When you change back-end server side code, the c# must be recompiled and this cannot be done without restarting the app. Hot reloads are supported for front end changes to HTML, CSS, and Javascript files however.

IIS Express gets stuck and css styles sometimes not being applied when debugging an ASP.NET MVC application from Visual Studio 2013

I am debugging an ASP.NET MVC app from Visual Studio 2013. When I start the debug process from Visual Studio, IIS Express where app is hosted gets stuck (my app is not started). It often happens to me. In this situation, I manually stop IIS Express from the tray icon. Even stopping IIS Express from the tray icon I often need to stop manually the debugging from Visual Studio through the stop button. Once debugging is stopped, If I try to debug again it does not work, well, sometimes works and sometimes not, it is random. I have verified that if I clear all browser history and cookies, it works in most cases except for some time. Also I have observed that Visual Studio 2013 takes a long time to boot IIS Express where my ASP.NET MVC app is hosted. Finally, I have observed that my ASP.NET MVC app hosted in IIS Express sometimes is not being displayed correctly when debugging from Visual Studio, I mean, it is displayed without css styles being applied, it seems like css styles are missed. In this case, if I stop debugging and start it again it works.
So How can I improve or solve these kind of weird issues?
IIS Express gets stuck and css styles sometimes not being applied when
debugging an ASP.NET MVC application from Visual Studio 2013
This is a quite strange issue and l suggest you could try these suggestions
Suggestion
1) delete all caches under C:\Users\Administrator\AppData\Local\Microsoft\VisualStudio\12.0\ComponentModelCache, C:\Users\Administrator\AppData\Local\Temp and C:\Users\Administrator\AppData\Local\Microsoft\WebsiteCache.
2) close VS Instance, delete .vs hidden folder,bin,obj folder under the physcial path of the solution and then reopen your project
3) If you have IntelliTrace, please disable Enable IntelliTrace under Tools-->Options-->IntelliTrace-->General.
4) try another port like 56000 by right-clicking on the project-->Properties-->Web--> project url.
5) disable any third party extensions by Tools-->Extensions and Updates or just use devenv /safemode in developer command prompt for vs2013.
6) try to reinstall IIS on the control panel and if your IIS is not 10.0, I suggest you could download and use it.
In addition, VS2013 is too old and Microsoft does not continue to maintain it. So l suggest you could download and use the latest VS2019. It has more optimization and stronger performance than the previous VS and fixes some remaining issues from previous releases.

Unable to run the mvc5 project on IIS server

I wanted to publish the my mvc5 application on IIS server and gone through with some references and finally I was able publish the project (through file system) from visual studio 2017.. After all my efforts I'm able to see the below screen when I browse the URL.
But it is not I expected, my actual running application in localhost is shown below.
I want to run the my actual project in IIS URL. What I can do to achieve this.
EDIT:
For more info..
Initially I got the issue which is shown in below image. For this fix, I've enabled the Directory Browsing in IIS server for my application. After enabling I face the above mentioned issue (shown in first image).
Any kind of suggestions are more helpful.
#Lex Li as you mentioned, the issue is caused the wrong CLR related settings for the application. And its my bad, I had used DefaultAppPool. Fixed the issue by giving the application pool as .Net v4.5. And also turned on the .Net extensibility 4.7 feature (in control panel -> programs and features -> Turn windows features on or off) as shown in below.
Now the application is running as expected in IIS server.
Thank you for all your comments which helped me to dig more into this. :)

Visual Studio 2013 not hitting breakpoints

I'm working with an ASP.NET solution in Visual Studio 2013 that fails to hit breakpoints. Visual Studio will successfully hit breakpoints on other solutions, and the breakpoints in this solution previously worked. But at this time they fail to work.
I'm using Visual Studio 2013 Ultimate, Update 4. This is installed on Windows 8.1, 64-bit.
This is an MVC solution that contains 3 projects: BusinessEntities, DataAccessLayer (DAL), and a Web project. Breakpoints in all of these projects fail to work. I even tried a breakpoint inside the Index ActionResult for the home controller, and that still failed to stop at the breakpoint.
In the Visual Studio ribbon, solution configuration is set to Debug. Additionally, Configuration Manager shows that all 3 of my projects have a configuration set to Debug. Restarting IIS, restarting Visual Studio, and rebooting did not fix this problem. Selecting Build > Clean Solution, Build > Rebuild, and then Debug > Start Debugging did not fix it either.
In web.config, debug is set to true in this node:
<system.web>
<compilation debug="true" targetFramework="4.0" />
There are .pdb files in the bin directories of my projects. I verified that they are getting deleted when the solution is cleaned, and recreated when it's rebuilt.
What else do I need to check? I really need to get the breakpoints working in this solution. Thanks.
========
Updates on 12/30/2014 - Below are several things that I tried, following comments from #paul.abbott.wa.us. Several comments I made are deleted and just appended here for clarity.
========
I'm starting the app via VS, and running it under IIS. The version of IIS is 8.5. When exposing the process name (via System.Diagnostics.Process.GetCurrentProcess().ProcessName), it's w3wp.
In IIS, the web application has a site name like "local.mysite", and there is a matching entry in my hosts file. The site uses the DefaultAppPool, which employs the .NET CLR version 4.0 and the Integrated Managed Pipeline Mode. The 3 applications in my solution target .NET Framework 4.
If I switch this back to IIS Express, the debugger starts working. The version of IIS changes to 8.0, and the process name is of course iisexpress. Technically I don't have to run this under IIS on my workstation, but I would prefer to do so. What have I misconfigured or overlooked in IIS that could account for the debugger failing?
Reviewing the project server settings on the Web tab of the properties page, I noticed the dropdown was set to "IIS Express". Upon toggling that to "Local IIS", I was prompted to run VS as Administrator. After doing that, I was able to alter the server to Local IIS, and hit the debugger. I checked in the change, closed VS, launched VS not running as Admin, and loaded the solution. The web project failed to load with the following message: The Web Application Project [MySiteName] is configured to use IIS. Unable to access the IIS metabase. You do not have sufficient privilege to access IIS web sites on your machine.
Eventually some sections of this site will employ Active Directory authentication. So, is the solution that I need to either run the site under IIS Express, or always run VS as Administrator if I wish to run the site under IIS? Thanks.
I found a solution to get past the error message of “The Web Application Project [MyApp] is configured to use IIS. Unable to access the IIS Metabase. You do not have sufficient privilege to access IIS web sites on your machine.” Follow the steps at this post. Error - Unable to access the IIS metabase
After granting my account access to the intetsrv\config folder, the web project properly loaded in Visual Studio without running VS as an administrator.
But now when I launch the site another alert appears: “Unable to start debugging on the web server. IIS does not list a web site that matches the launched URL. Click Help for more information.” Initially I just clicked “Create Virtual Directory” and launched again, but that same alert reappeared.
So I selected the Help button from the alert. That leads to this MSDN page, which proposes about 2 dozen things to check, with about half as many links to other articles. I'm feeling a bit like Alice in Wonderland right now, heading further down the rabbit hole.
2/3/2015 Update: My workaround while running this on the local IIS instance was to run Visual Studio as an Admin. Ultimately, we changed the app to use IIS Express, then later abandoned the app for another solution that a coworker built. That decision had nothing to do with this problem. Thanks everyone for your feedback and ideas.
3/7/2016 Update: At this time I'm unable to replicate this issue, as we no longer have the solution in the state where it was when I worked on it last year. I would be grateful if a moderator could close this question. The options for closing this don't align with my current scenario, but perhaps someone else will find the suggestions below useful if they encounter this scenario. Thank you to everyone who contributed a suggestion.
Make sure that:
Tools -> Options Debugger "Enable Just My Code" is unchecked
You are running the application in the Debug mode, not Release mode
Solution build is up to date.
I met this problem before and solved it after I rebuild the solution package.(right click solution package and run rebuild)
Here is a list of ideas I keep for such an occasion.
Check where your dll is being referenced from and ensure that is the code you're trying to debug.
Check you are in the correct mode when building: Debug/Release as they may put the dlls in different places.
Are you attached to the correct process?
For a website on IIS, is the code you're working on the same as the code running in IIS?
Go to Debug > Windows > Modules and if the relevant dll is there, right click it and load symbols.
If it's not in the list, try running the code anyway. Sometimes even though it says the breakpoint will not be hit, it's only because the dll is not loaded until you enter a scenario that needs it. Try the scenario that depends on the dll, and it may just hit the breakpoint anyway.
Restart your browser. You might have something cached from an older dll.
From my previous experience please consider these :
Check you have put the break point in a right place and you are running the appropriate page or controller
Right-Click on the break point => Location => Check "Allow Source Code to be different from the original version". If you have installed resharper , It's probably help.
If you are calling through Ajax call , Make sure you have not java-script error on the page ( for this IE catch js errors by default)
Some times it's because of not building thoroughly , So cleaning the
solution ( right-click on the solution and choose "clean solution"
item ) then "Rebuild Solution" .
Some times it's because you may have disabled the build option for
some class libraries , So in this situation you need to rebuild those
class-libraries exclusively . (you can find it out by check choosing
"Configuration Manager" item from the "Build" menu)
Hope these help

Debugging MVC application in VS2012 attempts to start IIS Express twice

UPDATE
I'm certain this is a Visual Studio bug with no obvious solution. I've encountered a number of people who have the same exact issue. I have submitted a bug ticket with Microsoft here:
http://connect.microsoft.com/VisualStudio/feedback/details/778864/vs2012-is-spawning-two-iisexpress-processes-when-attempting-to-debug
If you are having the same issue as described below, please go vote up the bug ticket so that it gets more attention.
Whenever I attempt to debug an MVC3 (or MVC4) application in Visual Studio 2012 configured to run on IIS express (version 8), I get the following error:
Here's the kicker: IIS Express is starting, even though Visual Studio doesn't think so and the debugger fails to attach. The IIS Express tray opens and I can clearly see all configured websites are started:
Oddly enough, the IIS Express System Tray reports that there were some errors when running IIS Express. Here's what it says:
This is a serious WTF. It's reporting that 8080 is being used by an IIS Express Process - the one that was just started by Visual Studio. So, Visual Studio is attempting to launch IIS twice, and when it predictably fails the second time, the debugger bails. I should note that before launching the debug configuration in Visual Studio, I made absolutely sure no IIS Express processes were already running. I used Process Monitor to verify that Visual Studio is in fact attempting to launch IIS Express twice:
Notice in the screen shot above you can clearly see websites running on IIS Express PID 4732. PID 4924 is the second failed attempt at launching IIS Express.
This issue was initially occurring on a Windows 7 installation. I reformatted completely, installed a fresh copy of VS2012, and got the same issue. I went a step further and reformatted, installed Windows 8 and a fresh copy of VS2012, and the issue persists.
I have created brand new blank MVC3 and MVC4 projects. Nothing fixes it.
I'm tearing out my hair here. Any help would be greatly appreciated.
w.Brian, I have followed this post since it's start and have had the exact same problem for quite a while now and I have just discovered what is causing the issue for me. I have been able to reproduce and fix the error for myself with this:
The reason VS2012 is starting iis express twice is related to being attached to a domain and being logged into a domain account. Once I logged into a completely local admin account I was able to launch and debug an MVC4 application without any issues. This is using Windows 8 Pro, VS2012 Update 1, attached to my domain, and no other software/extensions/configuration. Completely clean installation.
Hi maybe this solutions could help you.
Manage RuntimeVersion=”4.0″ to “4.0.30319″
Example:
<applicationPools>
<add name=”Clr4IntegratedAppPool” managedRuntimeVersion=”v4.0.30319″ managedPipelineMode=”Integrated” CLRConfigFile=”%IIS_USER_HOME%\config\aspnet.config” autoStart=”true” /><br/><br/>
reference:Issue: Visual Studio 2012 > “Unable to launch the IIS Express Web Server”
Use Process Monitor to solve the issue
reference: Debugging the “Unable to launch the IIS Express Web server.” error from Visual Studio 2012.
Try switching to the visual studio built in web host and run it. After you run it once you should be able to switch back to iis express
reference: from the forum Unable to launch the IIS Express Web server
try re-installing Visual Studio 2010 SP1, which contains iis-express.
disable the logging module by modifying the applicationhost.config, which is located in the %userprofile%\documents\IISexpress\config directory. To do so you will need to comment out a couple lines in the file.
Under the / element, comment out the line
<add name="HttpLoggingModule" image="%IIS_BIN%\loghttp.dll" />
Under the // element, comment out the line
<add name="HttpLoggingModule" lockItem="true" />
After saving your changes try restarting iis express.
reference: from stackoverflow forum: Unable to launch the IIS Express Web server
Right click you MVC project /*all of them one by one*/
go to properties
go to web tab
you must be having having checked "Use local IIS webserver" radio box
in the textbox below it make sure no to projects have the same port which in your case is 8080
Have a look at the answer here:
http://forums.asp.net/t/1953087.aspx?VS+2013+Unable+to+launch+the+IIS+Express+Web+Server
It was strange behavior on a Windows 8 machine when 'bg' was part of the username
I might be a little late to the party - here's my two pennies:
a) http://saintgimp.org/2012/05/03/fixing-the-error-unable-to-launch-the-iis-express-web-server-failed-to-register-url-access-is-denied/
b) http://abhijitjana.net/2010/07/20/unable-to-start-web-site-on-iis-process-can-not-access-the-file-because-its-being-used-by-another-process-how-to-resolve/
Synopsis: There is a URL reservation for the current port (usually Skype)
Just in case, do you have 127.0.0.1 localhost defined in folder/system32/drivers/stc/hosts ? Otherwize, you can check here, this might just be the key.
Cheers
I had the same issue on Windows 8 and Windows 8.1 using my domain account. In my case changing the Documents folder path (Right click on the Documents folder -> Properties -> Location) from C:\Users\username\Documents to D:\Documents helped
This week, I experienced this identical issue: IIS Express starts, but VS complains it couldn't start IIS Express and debugging fails.
I finally resolved the issue by applying the June 2014 hot-fix to IIS Express:
http://www.microsoft.com/en-us/download/confirmation.aspx?id=43380
We (my IT support and I) found this hotfix after stumbling over and following a very unlikely problem. Apparently, MS verified a bug in IISExpress 8.0 which results in it misbehaving if any part of the application name contains the letter combination "bg" (my username begins with bg):
https://connect.microsoft.com/VisualStudio/feedback/details/848945/visual-studio-2012-iis-express-fails-to-start-if-application-name-contains-bg
Note: VS 2013 Update 4 already contains this fix, which may be why some people had success simply by updating to VS 2013.
Some other links we found concerning the issue (you may have to skim a bit to find the topic):
http://forums.asp.net/t/1953087.aspx?VS+2013+Unable+to+launch+the+IIS+Express+Web+Server
https://connect.microsoft.com/VisualStudio/feedback/details/865116/process-with-an-id-of-id-is-not-running
What worked in my situation was to unload the project, then to edit the csproj file. I removed all sections regarding IIS and IISEXPRESS. Then I reloaded the project and chose USE IIS EXPRESS from the project properties all over again. It then worked.
I ran into an identical issue today (IISExpress trying to start twice and failing when hitting Debug in Visual Studio) while helping another developer with a web forms site. After trying several solutions, we found that we could resolve the problem by:
Creating a new, empty Visual Studio solution
Adding an "Existing Website" pointing to a new, empty folder
Copying the contents of the existing (non-working) website into the new folder we created
Simply removing and re-adding the website to the original solution did not work, nor did creating a new solution and adding back the existing site. I can start IISExpress from the command line just fine.
After doing a before-and-after comparison of the .SLN files I believe that is where the problem lies. Since I had found a workaround I didn't spend a lot of extra time on it. Obviously recreating the entire solution from scratch may not be an option for larger projects (ours was a very small one) but hopefully this at least points in the right direction.
There are two instances of the site FrontEnd running of course, but notice that one instance is HTTP and the other HTTPS.
It's possible to get two instances when SSL Enabled is set to True in the web site properties but the Project Url on the Web tab is set to an HTTP address.
Make them both HTTP (or HTTPS) and that might fix it.

Resources