Debugging from a View file - visual-studio-2010

Working on a C# MVC project, I can have multiple files open in Visual Studio. When I press F5 to start debugging, the debugging starts if the currently open file is:
a controller (*.cs);
a model (*.cs);
a stylesheet (*.css);
a config file (*.config);
a partial view (*.cshtml)
However, if the open file is a View (*.cshtml), the browser opens with the "Server Error - URL not found" page.
Additional info: The solution has always been under source control with SVN but at some point, the repository location changed and from then on (I think), this strange error occurs. It didn't happen before, I could debug without thinking if a view file was open or not. The change wasn't performed by me and I lack details on it. I am not sure these things are related either.
Anyone has come across a similar issue? How to solve it?

I am guessing the problem is your project setup. Do following:
Project right click -> Properties -> Web -> Start action
Most likely it has "Current page" checked, which does not play well with ASP.NET MVC view, it just tries to open the view directly, and not via route. Every other type of file you mentioned is not detected as page, and thus VS does not try to open them as such.
You might want to choose a "Specific URL" there, or just make a habit of switching to a different file before hitting F5.

Related

VS2015 Multiple startup projects - prevent page showing

I have recently had to reinstall my development machine so I'm unsure how I did this before.
A solution which I have currently has 3 projects that are needed for startup for debugging, this works fine, when I run the solution I get 3 pages open up in the browser which makes logical sense, however on my previous installation of my machine I only had one page open up, the API and MVC projects didn't show in the browser, but they were running so the entire application worked.
Is there a way to suppress the unneeded pages from opening up in the browser?
I found the option after a while, it was in the project properties, not the solution properties!
Here are the details if anyone is interested:
Right-click on the Project
Choose Properties
Go to the Web tab
In the Start Action section select the 'Don't open a page.
Wait for a request from an external application.' option.

In debug mode, the dynamically generated script file doesn't reflect saved changes

In VS 2010, I have an asp.net web application project. I made a change to a java-script file and saved it. I then run the application in debug mode and looked at the corresponding dynamically generated java script file. The dynamically generated file still represents the code before i made the recent changes. I tried restarting VS and my computer to no avail... This issue just started happening for no apparent reason.
Thanks,
Right click on solution, and click clean.

Issues editing ASP.net Razor view files while debugging

I am building an MVC3 application using RAZOR in VS 2010. TFS 2010 is being used for source control.
When debugging the application, it is helpful to be able to modify the Razor view files on they fly. If I open a checked-out view file in VS2010 before I start debugging, I can edit this file while I am debugging. If I open it after I start debugging, it cannot be edited whether it is checked out or not.
Interestingly enough, if I open a read-only file after I start debugging and begin to type in the view to edit it, the file is checked out from source control, but cannot be modified. Additionally, when I stop debugging, I must close the file and reopen it in VS in order to edit it.
Just to clarify, if after I start debugging, I open a view file I already had checked out (not read-only), I cannot edit this file. When I stop debugging, I have to close and re-open the file to be able to edit it.
I have edit and continue turned on, and it works as expected for the controllers and models.
It feels like there is a setting that I am missing somewhere.
Thank you for your assistance.
I've suffering this bug for more than a year. See my question about the problem here: Edit a view in Runtime
This hotfix solve the problem for me.
http://connect.microsoft.com/VisualStudio/Downloads/DownloadDetails.aspx?DownloadID=40811

Workflow Foundation: Designer is not working

When I try to open any activity in design mode designer fails with message "The document contains errors that must be fixed before the designer can be loaded. Reload the designer after you have fixed the errors". The project builds and runs fine though. This happens even with a fresh newly created solution. I mean that if I create a new workflow project and add a new item -> activity the problem persists.
If I click "Reload the designer" I get the following error: "Undefined CLR namespace. The 'clr-namespace' URI refers to a namespace 'System' that is not included in the assembly". If I build the project the error disappears but the designer doesn't start working.
I'm using VS2010 Premium. The only plugin installed is ReSharper. However I tried removing it but it didn't solve the problem. I've also asked a friend of mine to reproduce the same error on his computer but everything worked well.
The problem was that there are several types of editor for .xaml files. If you right click open with you can choose one of them. In my case WPF designer was selected by default though it's better to choose automatic selection.
Hope this information will be helpful for someone else :)

generation of designer file failed

Every few days VS2008 decides to get mad at me and fails to generate a designer file claiming it cannot find the file specified and that it's missing an assembly. Here's the scenario:
The aspx page has a reference to a custom user control (inheriting UserControl) which references another assembly in the backend. There are many other references to this "missing" assembly in other places in code which don't throw errors. rebuilding, updating the source to the clean copy, shouting at the computer, punching the screen, etc all fail to work.
Any suggestions? This is quite annoying.
We've had similar problems before, unfortunately I don't remember the exact solution.
If your using a "Web Site" project (no project file) then start by checking that both your page and your control both set the ClassName property in the first line of your aspx/ascx file and that you specify the full name of the class including the namespace.
Example:
<#Control Language="VB" AutoEventWireup="false"
ClassName="YourProjectName.YourUserControl"
Inherits="YourProjectName.YourUserControl"
CodeFile="YourUserControl.ascx.vb"
%>
Many times not setting all of these will still work but you will get odd compiler errors and behavior in VS.
If you using a Web Site Application project try deleting the designer file manually and then right click on your project and choose "Convert from Web Application." This will should recreate the designer file for you.
My only other suggestion would be to recreate the page and/or the user control from scratch.
Jared, you've hit it. Using "Convert to Web Application" to manually generate the designer file solves my problem. I'm glad you posted this before i started reinstalling. Thanks.
You might try archiving a template of a new file with its designer equivalent. If VS coughs then you can do an "Add Existing" option with the file you already have.
It seems, however, to be an issue with your installation of VS2008 so you might try reinstalling it.
I found that using a custom control, you would need to add a reference to the .dll. This fixed it for me after migrating from a web site to web app.

Resources