How to debug the client side code from within studio? - asp.net-mvc

I am trying to debug the client side code (like JQuery code, JavaScript code) from within visual studio.
Wondering how i can do that?

You have to enable debugging in Internet Explorer. In Internet Options there's an option, checked by default, called "Disable Script Debugging (Internet Explorer)." Uncheck this option and close Internet Explorer.
After that, you can use VS to attach to a running instead of IE and set breakpoints in the code. The full features of VS's debugger will be available and it works great.

In VS 2010 (and VS 2008 I think) while running the web solution in debug mode using internet explorer, if you go into the Solution Explorer there will be a "Script Documents" node, with an "Internet Explorer" node beneath this and all the java scripts that are in the page will be listed. You can double click on any of these scripts to open them and add breakpoints to the java script as required.

FireBug is much better javascript debugging tool compared to Visual Studio. I would strongly recommend it to you. Google Chrome developer tools are also worth checking.

Related

Context menu missing in Visual Studio 2022

The project that I'm working on uses the Visual Studio (2022) extension 'Unchase OpenAPI (Swagger) Connected Services' to generate a C# controller. My colleague and I have both followed a tutorial on Medium to setup this extension, and we have both installed version 1.7.1. However, in the solution explorer, I don't get the context menu item to update the connected service whereas my colleague does. The attached picture shows my environment (upper) and his (lower), and as can be readily seen, I'm missing an option.
So far I've tried to disable and enable the extension, restarting VS, and even restarting the PC.
Any idea why I cannot update the connected service?
It seems it is a bug in Visual Studio 17.2.x. Workaround is to use NSwagStudio, but the template folder has (if you use it) is now relative to a temporary folder, not the one .nswag definition resides into.
https://bytemeta.vip/repo/unchase/Unchase.OpenAPI.Connectedservice/issues/70

Visual Studio 2019 not showing 'View in Browser' option

I'm taking a course in HTML & CSS that requires Visual Studio 2019. I've written the exact script shown in the video over and over but there is no option to 'View in Browser'. I have no previous experience with JavaScript and very little Visual Basic. I've never used visual studio before.
I've uninstalled and reinstalled VS several times with the same problem.
Please help me!!
One of the examples I'm asked to type:
There is no option to 'View in Browser when right clicking or clicking the File tab.
I tried the solutions offered for VS 2017 but they did not work.
My laptop is a fairly new HP with Windows 10 installed.
Below is what comes up when I right click on the script.
enter image description here
If your HTML file is part of a project in Visual Studio, then here is one way to view your file in a browser.
Right-click on the project name in the Solution Explorer window
Select View > View in Browser
You may need to manually change the URL in your browser to get to your HTML file.

Uploading file in MVC project under Debug forces program to exit debug mode

So, I create new empty/MVC project, add simple controller and view for uploading file, lauch program under the Debug mode and trying to upload file.
After selecting file (immediately, right after chosing the file in explorer!) program exits debugging and I'm getting 404 in my browser.
When lauching project without debugging everything works good, but this is not a solution... what if I need to test uploading exactly in the Debug mode?
In ASP Core I'm getting the same issue.
I've tried different variations of code, including version of A. Freeman, published in his book "Pro ASP.Net MVC 5" - nothing works.
This is a bug of visual(I am not sure). You can fix this by change keyboard of visual studio to Visual C# 2005. You should run in Chrome, Firefox or Microsoft Edge. Others browser is not compatible.
You can find keyboard settings in Tools -> Options -> Environment -> Keyboard
Change setting to Visual C# 2005 -> Ok. Restart computer or visual studio. It will works!

Umbraco MVC4 IntelliSense not working

I'm working on a few Umbraco projects that use MVC4. The MVC intellisense doesn't work within visual studio and I get lots of errors underlined. But when I run build the project, I don't get any errors, and when I run the site everything works fine.
I'm using Visual Studio 2013 and I created a new MVC4 site and compared the web.configs within the Views folder and they're identical.
I'm pretty sure it's not a code problem as my colleague is using the same code and he doesn't have this problem.
I've just done a fresh install of Visual Studio 2013.
Any ideas?
This could be a clue:
When I hover over #Htmlit tells me that my HtmlHelper is a System.Web.WebPages.Html.HtmlHelper instead of a System.Web.Mvc.HtmlHelper
The common one is to ensure that it is switched on (Visual Studio menu: Tools > Options > Text Editor > All Languages (or C# if you want it just for that language) > Tick "Auto list members", Untick "Hid advanced members", tick "Parameter information")
Once you've checked this, sometimes if you're using one HDD on Windows, because the disk has its bandwidth used up (particularly if using ReSharper then you need two or more drives ideally with the pagefile going to the non-OS drive I find). This is the case if the red lines do disappear after up to two minutes of not touching the IDE.
Finally check you project's references folder to make sure where the paths for your includes are coming from and that Visual Studio has permission to read from there. Permission issues cause all manner of problems I find, so when you launch VS, right click and choose "run as Administrator".
Hopefully one of these solves your problems. If not, then please update your question to explain how you create your project. Do you create an empty site or an MVC site? Do you then use Nuget to install Umbraco through the Package Manager Console like this?
Install-Package UmbracoCms

How to set web folder for debugging in visual studio?

When I am debugging web project in visual studio the web address is for example localhost:1234/index.html, but when I publish project the web address will be like *http://myserver.mydomain.com/myApplication/index.html.
Is there a way to set in visual studio to debug it on localhost:1234/myApplication/index.html.
I am accessing few scripts and css and services and it will make my life easier if they will be on same level during debugging and publishing.
Right click on the project, click Properties Window and add /myApplication as the Virtual Path. Or you can use View->Properties Window from the main menu.

Resources