I've just started working on an MVC 4 app, using Visual Studio 2010, got the app building, but alas am still waiting to get admin rights to my Windows XP box.
...and I don't seem to have any way to run the app in my browser. The startup project is a class library, so I can't run it directly by F5ing, and I lack (probably due to not having admin access) the normal options to set the server configuration in the Debug panel in the project's properties.
So what's the best option for me, anyone? Or is this intractable without admin rights?
EDIT: With MVC, make sure the startup project type is Web Application, not Class Library. I forgot this! If you need to change, see this question. And the problem had nothing to do with not having admin rights.
Right click on the MVC project, Debug->Start New Instance
I am also facing the same issue.
I just modified the csproj file of that project.
I added
<ProjectTypeGuids>{349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}</ProjectTypeGuids>
to the project.csproj file and reload the application and found my solution working at next moment.
With an MVC 2.0 project in VS 2010, the default (and only) output type is ClassLibrary. For me it turned out to be something really stupid. I had accidentally set another class library project in the solution as the StartUp Project. Right click your MVC project in Solution Explorer, and choose "Set as StartUp Project". It should appear bold in the Solution Explorer if it is the designated StartUp Project.
Related
I just created a new MVC application from VS 2015. Target framework is .NET 4.5.
In the first debug, it shows
Value cannot be null.
Parameter name: httpBrowserCapabilities
Exception Details: System.ArgumentNullException: Value cannot be null.
Parameter name: httpBrowserCapabilities
And the stacktrace points to: System.Web.HttpBrowserCapabilitiesWrapper..ctor(HttpBrowserCapabilities httpBrowserCapabilities) +3511141.
What could be wrong here? I reinstalled Visual Studio yesterday but it still won't fix. What can possibly break this httpBrowserCapabilities?
Reinstalled my Visual Studio, no fix.
The whole situation looks like what is described in these posts:
Webmatrix and iis 8. Default project doesn't not work
Webmatrix only error with ajaxtoolkit.
It just happened suddenly and there is just no way to fix!
It looks like some code somewhere is trying to use HttpBrowserCapabilities to do browser detection. Weird thing is that MVC does not use this at all, and in fact, the only usage of it I can find is in conjunction with Web Forms server controls. If this is truly just a scaffolded project, without any additions by you, then it's possible you chose the wrong project type (though I have no idea why any built-in project scaffold would throw exceptions by default).
Regardless, my best advice is to simply create a new solution, and make sure you choose "ASP.NET Web Application" as your project type.
This is only a makeshift.
I find I could use Local IIS instead of IIS Express to run the web applications.
So it appears something is wrong with the IIS Express. But a re-installation of Visual Studio won't fix it. Neither could a re-installation of .NET framework do.
Anyway, since I have a local IIS, I just change the Servers properties in the application's Properties, Web tab. Have to run Visual Studio as Administrator. And check Override application root URL.
So now I am back in working mode. I will look into how to fix IIS express later. If anyone has a better solution, please share with us. Thanks.
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
When I try to run my application, I ge the the following error;
I know this issue has come up many times, and the usual answer is to right click on the appropriate project and make it the start up project.
Well I have done that and this does not fix it.
My application is an MVC application, so the start up project should be a class library.
It was working fine until I tried to upgrade it to MVC5.
I am working on VS 2012.
I am wondering if the problem was caused by unloading and reloading the csproj file which I edited as part of the upgrade?
I think it might have something to do if there are multiple projects in the solution. I was getting the same problem when I had a MVC project and the testing project in the same solution. What fixed it for me was setting the MVC project as the StartUp project. This is done by right clicking on the MVC project and selecting "Set as StartUp Project".
This works for VS2013 Professional
I had the same issue and corrected by altering the projecttype guid. Here is an example:
<ProjectTypeGuids>{349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}</ProjectTypeGuids>
I had a solution that included both an ASP.NET MVC web project and a WebAPI project. The solution was created originally with VS2012, but I recently upgraded it to VS2013.
I just noticed when going to add a controller that I'm not getting the correct options in the right click menu. For instance if I go to the web project and right click the controllers folder, the option to add a controller isn't there. Instead I have add WebAPI controller. It's exactly the opposite for the WebAPI project.
Things seem to build and run ok so far, but it's going to be a pain manually adding things and I'm wondering if something else might break. Any idea why this is happening or how to fix it?
I would guess that project type is different in your csproj. Take a look at this question:
What is the significance of ProjectTypeGuids tag in the visual studio project file
Here is what I have on my machine for c# asp.net mvc project:
<ProjectTypeGuids>{349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}</ProjectTypeGuids>
Take a look at your guids and see what they mean.
You could see the meaning of the different GUID in the register :
•HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\10.0\Projects for
ProjectTypeGuids
•HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\10.0\Packages for
packages reference by some project
I have a Visual Studio 2010 Solution that contains a few library projectes, a few WPF projects and an ASP.NET MVC 3 project. When i start any project the MVC project get started in the development-server.
Is there some way to stop this behaviour?
Edit:
I just checked to make sure I´m to doing too much wrong. If you start a new solution with a console/whatever project and add an mvc3 project, everytime you start the console project the mvc project gets started as well.
Not sure if this is buggy or an intended feature, but it is kind of strange that the behaviour is so different from normal projects.
If you don't need MVC project for certain period of time, you can unload it (Right-click on the project and select Unload project).
Another option is to select local IIS as a web server (If you have it installed). This way it won't start development server.
You can always choose another project as the default project to start up. You can right-click on the project and set as startup project.
Make sure all your web projects are set to use local IIS rather than the Visual Studio Development server. Unlike the development server, IIS doesn't do anything with a new build until you actually try to load a page.