Yearly Archives

20 Articles

Visual Studio Tips

Getting Started with Application Insights

Posted by matteskolin on

Here is a microsoft link to show excatly how to enable Application Insights in Visual Studio..

https://docs.microsoft.com/en-us/azure/azure-monitor/app/asp-net

Configuring Application Insights even for a local application appears to require an Azure account.

Once configured, telemetry data is immediately sent to Microsoft from where the application is running, i.e starting a debug session in visual studio will start collecting telemetry.

You can view the insight data inside of Visual Studio , by navigating to more windows -> Application Insights Search

View.ApplicationsInsightsSearch is the Visual Studio command here for anyone wishing to avoid the navigation fatigue and headache of having to navigate all the way through Other Windows; I have mapped Application Insights to Cntrl + 0 for my environment.

The Visual Studio Insights search allows you to view Insights from a single debug session, or to pull all the insight data from an Azure Resource.

There are several different filters available on the left “Refine By” column. I was confused at first clicking the filter checkboxes as nothing would seem to happen, and all my data was still showing. It turns out you must click the update button circled in blue above to apply all filters and refresh the main view.

So far I only have Server Response Time metric, and Requests in my insights.

This system looks like it could be useful to identify trouble spots in the application where users are having issues, but not issues serious enough to become bug reports.

Also without this telemetry, I have not seen in the default site templates anything that tracks requests at this level of detail. When working with a larger application it would be help to know what parts of the application are hit the most, and which parts are rarely or never used.

This can help teams know what bugs to focus on and where the site may need to be optimized for speed as well.



Visual Studio Tips

Using Visual Studio Browser Link to Speed Up Development

Posted by matteskolin on

I just discovered how to use Visual Studio browser link. This feature creates a constant connection between the browser and visual studio, allowing Visual Studio to trigger refreshes in the browser.

I had been under the impression that the only purpose for browser link was to test code in multiple browsers, to check compatibility, but I learned that it can also be used when working with a single browser to speed up the development process.

Specifically, the benefit comes when starting the application without debugging (Control + F5). When you start the application without debugging you are able to edit the code while the application is running. Normally, If you change assembly files, and then refresh using the browser, the application will automatically recompile the changed assemblies.

With browser link, you do NOT even have to refresh the page in the browser. You can trigger the refresh from within Visual Studio by clicking on “Refresh Linked Browsers” from the toolbar.

I am using Visual Studio 2019 Enterprise Preview with a .Net Core 2.2 MVC project. Seem Image below. I think it is essential here to create a shortcut to refresh linked browsers. I created mine to be (Control + `). The below screenshot shows another shortcut I tried that did not work because Ctrl + L is bound to so many different actions in my environment.

Enabling Browser link in a .Net Core app

To enable Browser link in .Net Core, you need to call the method next to the comment below. This will cause some javascript to be output to the page to create the link. Also make sure “Enable Browser” link is clicked in the above screenshot.

 public void Configure(IApplicationBuilder app, IHostingEnvironment env)
 {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
                app.UseDatabaseErrorPage();

                //Enable Browser Link
                app.UseBrowserLink();
            }
}