Visual Studio 2012 Launches Wrong Project For Debugging - asp.net

I've got an ASP.NET web application project in a Visual Studio 2012 solution. I'll refer to this as A.
I copied A's directory to a new directory to make a clone of it. I'll refer to this as B.
I made extensive changes to both A and B to the point that they are not even remotely similar. Stylesheets, scripts, HTML, and back end is all different.
I launched A for debugging, and it appeared in my browser as expected. I debugged the application for awhile, and then terminated debugging via the "stop debugging" icon on the toolbar within Visual Studio 2012.
I then launched B for debugging. Instead, I got A.
I tried clearing browser cache, though, this couldn't be the problem because the server side of the application was wrong too.
I tried Rebuilding the project, after running Clean. I still see A while trying to debug B.
I tried killing all processes related to the debugging session including all iisexpress.exe, MSBuild.exe, WebDev.WebServer40.EXE, Microsoft.VisualStudio.Web.Host.exe instances.
I tried closing Visual Studio 2012 completely, reopening it, and retrying debugging.
EDIT
After closing and reopening VS2012 for a third time, it started now allowing me to see B. Nothing else has changed.
Best I can come up with is there must be some type of project setting that needs to be changed to reflect that the project lives in a different space than it did before being copied, but I have yet to track down such a setting.
What am I missing?

I have just come across this issue today, having done exactly as you (copied a project, and then edited). And hence i would like to share my solution.
If you go to Project B's Properties (found in solution Explorer), you will find a Web tab:
In your Servers section, alter the Project Url to:
http://localhost: + (number +1) + /
and then hit Create Virtual Directory
You should then be able to re-run your project and since they're running off different Url's, you shouldn't see this clash again.

I was in the exact same situation. The problem was that both projects (Project_A & Project_B) we’re setup to run on the same port in IIS Express.
IISExpress determines the port/application by looking at a configuration file located in <Documents>\IISExpress\config\application.config.
Open that file and look for a section <sites>. You should find a list of your VS projects. Locate your projects (A and B) and make sure that both projects are not running on the same port
<site name="Project_A" id="17">
<application path="/" applicationPool="Clr4IntegratedAppPool">
<virtualDirectory path="/" physicalPath="C:\Projects\Somefolder\ Project_A " />
</application>
<bindings>
<binding protocol="http" bindingInformation="*:64212:localhost" />
</bindings>
</site>
<site name="Project_B" id="18">
<application path="/" applicationPool="Clr4IntegratedAppPool">
<virtualDirectory path="/" physicalPath="C:\Projects\Somefolder\ Project_B " />
</application>
<bindings>
<binding protocol="http" bindingInformation="*:64212:localhost" />
</bindings>
</site>
If that is the case, remove one entry (i.e. Project_B), and then go in Visual Studio to recreate the entry.
In VS, go in the Properties of Project_B. Click on Web tab and look for the “Servers” section.
Enter a new port (i.e. `http://localhost:64213`) and click on the “Create Virtual Directory” button. This will add an entry in the “application.config” file, with the new association (i.e. Project_B / port 64213)
This should fix the problem. Hope this helps

This question is not marked as answered and as I had a similar problem I thought I would answer it.
you need to go to project > properties > web then check the use local web server box and overide application root if applicable, change the path names to the ones you are using save and it should work.

Related

VS 2015: Binding a WebApp to something besides localhost

I've got an VS WebApp I am testing (An OData Provider if it matters). The client is Android.
You can't run the server and client (via a simulator of the client' OS) on the same box.
So I'm using a physical Android device to run the client. Unfortunately Visual Studio is hell bent on binding the webapp to (and only to) localhost. It isn't won't respond to attempts to connect to the hostname or IP address, and any attempt to change the IIS configuration inside of Visual Studio meets with an error message saying you specifically must use localhost (which obviously cannot be used to connect to from a another machine)
1) How do I get around this?
and
2) If this isn't obvious to find, how are people are expected to test from a remote device on their development machine?
JoeHz,
You need to change the binding configuration of your IIS Express for your WebApp.
In the folder where your *.sln is, find the hidden folder named .vs. Then open the xml file applicationhost.config in the config folder.
In the applicationhost.config file, find the sites nodes, then the site you want to configure.
For example:
<site name="MySiteName" id="2">
<application path="/" applicationPool="Clr4IntegratedAppPool">
<virtualDirectory path="/" physicalPath="C:\MyDirecctory" />
</application>
<bindings>
<binding protocol="http" bindingInformation="*:8381:localhost" />
<!--Add new binding here with ip address-->
<binding protocol="http" bindingInformation="*:8381:192.168.0.10" />
<!--or add new binding with machine name-->
<binding protocol="http" bindingInformation="*:8381:MachineName" />
</bindings>
</site>
Once the file saved, make sure your IIS Express is closed and start your website. Once IIS Express started, check if the new binding worked, you should see something like this:
Ensure you can access the website in your web browser, not with localhost, but this time with your new binding like http://192.168.0.56:33617.
If all is good, then go to your Firewall, and add a new TCP rule for the port you need to open
When done, at that point any device on the same network should be able to access the website. Try the new address on your Android device web browser.
Your Android client should now be able to access your WebApp.

Adding a webServer handler causes duplicate key error in IISExpress when virtual path specified

I have an MVC5 app in VS2013. I need to add some handlers to the root Web.config. This works fine with no virtual directory, but when I specify a virtual directory, IIS Express fails.
This is easy to reproduce in VS2013:
Create a new ASP.NET Web Application. Select MVC and no authentication
edit the top level Web.config. Add the following lines to the bottom, right before the closing configuration tag:
<system.webServer>
<handlers>
<add verb="GET" path="*.png" name="Static for png"
type="System.Web.StaticFileHandler" />
</handlers>
</system.webServer>
</configuration>
The application will run fine. Now, go to the Project properties, "Web" tab, and add an application name like "WebTest" to the project Url. Click the "Create Virtual Directory" button and acknowledge so that VS will let you save.
build and run
You get an error 500.19 - Cannot add duplicate collection entry of type 'add' with unique key attribute 'name' set to 'Static for png' .
IIS Express is running the app at two URLs, one with the name and one without. The URL without the name (http://localhost:52065/) comes first and works fine; the one with the name comes second and has the error. By the way, VS2010 just runs the app with the name and this works fine.
Poking in the MyDocuments\IISExpress\config\applicationhost.config file, I see the two entries for the app, both pointing to the same physical directory:
<site name="WebTest" id="3">
<application path="/" applicationPool="Clr4IntegratedAppPool">
<virtualDirectory path="/" physicalPath="C:\_Dev\WebTest\WebTest" />
</application>
<application path="/WebTest" applicationPool="Clr4IntegratedAppPool">
<virtualDirectory path="/" physicalPath="C:\_Dev\WebTest\WebTest" />
</application>
I don't understand why there need to be two entries. I tried:
removing the first application entry. This causes an unrecognized
configuration path error.
duplicating the entire solution, and pointing the first entry at it. This gets the same duplicate error.
Some Context: I need the static handlers because this app has to be structured as a collection of independent dlls. I embed the content into the dlls
at build time and then use a VirtualPathProvider to intercept each path request and return a stream from the dll. I've found that this only works if the static file handler is in the root Web.config; otherwise my VPP doesn't get the request.
The dlls are in a Plugin directory under the project root directory. Putting a config file there didn't help either.
What am I missing? Is there a way to get IIS Express to run the app only with a name and avoid the duplicate key error?
You must always keep in mind, that ASP.NET applications under the same web site inherit parent's configuration. That means, the WebTest application will have one "Static for png" from itself, and another "Static for png" from its parent (the site root application).
Thus, as #hobwell pointed out, you must add a tag to avoid duplication.

VS 2013 / IIS Express - serve site from localhost:port/myapp instead of localhost:port

In prod my site (mvc5) is hosted on https://company.no/myApp/ where myApp is an Application on IIS.
In dev my site is hosted on IIS Express on http://localhost:54307/
As this causes some truble with server relative paths I would like to also do my debugging on http://localhost:54307/myApp.
This is what I've tried:
Setting project url in property pages to http://localhost:54307/myApp and clicking Create Virtual directory
Tried the override application root with or without the myApp url.
Tried modify the applicationhost.config. Currently my setting looks like this:
<site name="MyApp.Web-Site" id="38">
<application path="/" applicationPool="Clr4IntegratedAppPool">
<virtualDirectory path="/" physicalPath="C:\Projects\OP\MyApp\Main\src\MyApp.Web" />
</application>
<application path="/MyApp" applicationPool="Clr4IntegratedAppPool">
<virtualDirectory path="/" physicalPath="C:\Projects\OP\MyApp\Main\src\MyApp.Web" />
</application>
<bindings>
<binding protocol="http" bindingInformation="*:54307:localhost" />
<binding protocol="https" bindingInformation="*:44307:localhost" />
</bindings>
</site>
When I try to open page from the myApp folder I get the follownig error:
Module IIS Web Core
Notification BeginRequest
Handler Not yet determined
Error Code 0x800700b7
Config Error Cannot add duplicate collection entry of type 'add' with unique key attribute 'name' set to 'WSFederationAuthenticationModule'
Config File \\?\C:\Projects\OP\MyApp\Main\src\MyApp.Web\web.config
Requested URL http://localhost:54307/MyApp
Physical Path C:\Projects\OP\MyApp\Main\src\MyApp.Web
That indicates web.config loaded twice. Any idea what I'm doing wrong?
Thanks for any help
Larsi
I hear you with IIS Express causing problems with server relative paths. You can set this up with a couple steps that don't include manually editing your applicationhost.config. I try to avoid editing the applicationhost.config manually, it seems to cause more problems than it solves. I would remove the website from your local IIS to clear out any of that stuff and then do the steps below:
right-click on your web project and select properties.
Click on the "Web" menu
change the dropdown to Local IIS and enter the URL you would like the app to resolve to then click create virtual directory, save the file and build.
You can still debug without the port number, the debugger will just attach to this new website in your local IIS instance as long as you have a debugger option checked on the web tab.
open your local IIS and make any other configurations that are required for your app to run (Authentication, Application Pools, etc.).
open your browser and navigate to http://localhost/YourAppName
since this is a website as far as your local iis is concerned, you can hit it anytime in a browser without needed Visual Studio running.

IIS Application Initialization not Firing into ASP.NET Application

Running on Windows 8, I have enabled the Application Initialization feature of IIS from the Windows Features install options for IIS.
I'm attempting to get an ASP.NET Web app to start up immediately and fire into Application_Start when the Application Pool is restarted. I've followed the instructions from this tutorial, but after setting the values in the ApplicationHost.config, and web.config I see nothing is firing.
Here's what I've set (which seems to match what the article suggests):
<applicationPools>
<add name="MPress" autoStart="true"
enable32BitAppOnWin64="true"
startMode="AlwaysRunning">
<processModel identityType="LocalSystem" setProfileEnvironment="true" />
</applicationPools>
<sites>
<site>
<application path="/MPress.Workflow.WebQueueMessageManager"
applicationPool="MPress" preloadEnabled="true">
<virtualDirectory path="/" physicalPath="C:\Projects2010\Clients\MPress\MarvelPress.Workflow.WebQueueMessageManager" />
</application>
<bindings>
<binding protocol="http" bindingInformation="*:80:" />
</bindings>
</site>
</sites>
And then in the local web.config I have:
<system.webServer>
<applicationInitialization remapManagedRequestsTo="Startup.htm"
skipManagedModules="true"
doAppInitAfterRestart="true">
<add initializationPage="default.aspx" />
</applicationInitialization>
</system.webServer>
Other than the doAppInitAfterRestart flag this matches the settings in the above article exactly except pointing at my virtual app and application pool.
It appears that the Application Pool auto load works - if I stop and restart IIS w3wp I see the application pool show in the task list. But using Process Explorer I can see that the EXE hasn't loaded .NET just sitting there. No .NET Runtime dlls are loaded, so it appears that no request has fired.
What really sucks is that there's no real documentation of section and expected values required for each setting. The doAppInitAfterRestart flag is documented nowhere that I could find. I've also left that out with the same results. I'm also not 100% what the syntax for the URL is. The MSDN article points at "/default.aspx" and I tried that too to no avail.
I also turned on Failed Request Tracing in IIS to see if maybe the fake request fails somehow, but nothing shows up in there. It simply looks like Site Level load is not firing when the application pool restarted.
All of the settings mentioned here are also available through the IIS Admin UI in Windows 8 and everything certainly looks correct.
I'm out of ideas on what else to check or what I might be missing. Any ideas appreciated.
After some more spelunking it turns out that although I had installed the Application Initialization feature using the Windows 8 features, the actual module was not added to the globalModules list.
The following was missing and once added everything started working just fine:
<globalModules>
<add name="ApplicationInitializationModule" image="%windir%\System32\inetsrv\warmup.dll" />
</globalModules>
I faced similar issue but after doing a bit of comparison I found that you need to set Application Pool Managed Pipeline Mode to Integrated. It will not work with Classic Mode

Invalid application path

IIS7 Windows 7 64bit
No matter what I do I can't seem to add an application to a web site.
When I 'Test settings' I get "Invalid application path".
Any one have a guess as to what I could be doing wrong?
When I got this error it appeared to be due to a security setting. When I changed the "Connect As" property to an administrator then I no longer got the message.
Obviously this isn't a good solution for a production environment - one should probably grant the least privileges necessary for the user IIS is going to be using by default. I'll update this answer if I learn more.
The error message might be a bug. I ignored it and everything worked for me.
See Here: http://forums.iis.net/t/1177952.aspx
and here http://forums.iis.net/p/1182820/2000936.aspx
I eventually tracked this down to the Anonymous Authentication Credentials. I don't know what had changed, because this application used to work, but anyway, this is what I did:
Click on the Application -> Authentication. Make sure Anonymous Authentication is enabled (it was, in my case), but also click on Edit... and change the anonymous user identity to "Application pool identity" not "Specific user". Making this change worked for me.
Regards.
Go to your HTTP bindings in IIS (select your website, then on the right click on Bindings...).
Delete your SSL and your HTTP binding. Re-Add them.
This usually fixes this for me.
Try : Internet Information Services (IIS) Manager -> Default Web Site -> Click Error Pages properties and select Detail errors
Problem was installing iis manager after .net framework aspnet_regiis had run. Run run aspnet_regiis from x64 .net framework directory
aspnet_regiis -iru // From x64 .net framework directory
IIS Manager can't configure .NET Compilation on .NET 4 Applications
I was also getting this error, I found that it was because I had deleted the Default Application Pool "DefaultAppPool". Re-creating it fixed the problem. Drove me crazy for a few days.
This error will appear if either the web application is mapped to a non-existent app-pool; or if that application pool is stopped.
I also had this error.
My IIS Website has a Default Website with three (3) application directories below it.
I had each of my 3 application directories configured correctly to use .NET Framework v2.0 in the Application Pools.
However, the Default Website never was configured. I didn't think it was necessary since all of my apps were contained within it.
My IIS Server's default configuration is .NET Framework v4.0, so I changed that to .NET v2.0:
After I did that, I no longer received the same error message.
Now, I see this:
I hope this information helps others.
I was also getting this error. The problem for me turned out to be that I had two separate websites on the machine, and I had not designated which address went to which website. To resolve this, go to IIS Manager -> Select Web Site -> Bindings -> Add... -> Enter the host name that you want to resolve for this website. Repeat for any other websites on the machine.
HTH. Rick
I had a similar issue today. It was caused by skype! A recent update to skype had re-enabled port 80 and 443 as alternatives to incoming connections.
H/T : http://www.codeproject.com/Questions/549157/unableplustoplusstartplusdebuggingplusonplustheplu
To disable, go to skype > options > Advanced > Connections and uncheck "Use port 80 and 443 as alternatives to incoming connections"
I still haven’t find a solution, but find a workaround.
You can manually change IIS configuration, in system32\intsrv\config\applicationHost.config. Just manually create (copy-paste) section in <sites> and <location>.
This worked for me. (btw its not recommended.)
For my test app , I created a new application pool and changed its Identity to "NetworkService" .
More about App Pool Identities here
http://www.iis.net/learn/manage/configuring-security/application-pool-identities
and
http://www.iis.net/learn/get-started/planning-for-security/understanding-built-in-user-and-group-accounts-in-iis
You have to make sure that "NetworkService" has rights on your application's physical path.
even it was getting the above error. i found out that IIS was not registered on the server.
registering the iis fixed the issue.
Thanks,
In my case I had virtual dir. When I accessed main WCF Service in main dir it was working fine but accessing WCF service in virtual dir was throwing an error.
I had following code in web.config for both main and virtual dir.
<security>
<requestFiltering>
<denyQueryStringSequences>
<add sequence=".." />
</denyQueryStringSequences>
</requestFiltering>
</security>
by removing from web.config in virtual dir it fixed it.
I was able to correct the flaw by changing the file below:
C:\Windows\System32\inetsrv\config\applicationHost.config
In:
<application path="/" applicationPool="ASP.NET v4.0">
<virtualDirectory path="/" physicalPath="C:\inetpub\wwwroot\Bonobo.Git.Server" />
</application>
<application path="/Bonobo.Git.Server" applicationPool="ASP.NET v4.0">
<virtualDirectory path="/" physicalPath="C:\inetpub\wwwroot\Bonobo.Git.Server" />
</application>
For:
<application path="/">
<virtualDirectory path="/" physicalPath="C:\inetpub\wwwroot\" />
</application>
<application path="/Bonobo.Git.Server" applicationPool="ASP.NET v4.0">
<virtualDirectory path="/" physicalPath="C:\inetpub\wwwroot\Bonobo.Git.Server" />
</application>

Resources