Filtered by Tag (visual-studio)
Today is one of those awesome days if you build stuff on .NET platform. They announced bunch of stuff during Build 2015 keynote and one of them is Visual Studio Code, a free and stripped down version of Visual Studio which works on Mac OS X, Linux and Windows. Let me give you my highlights in this short blog post :)
@ 04-29-2015
by Tugberk Ugurlu

Today is one of those awesome days if you are building stuff on .NET platform. Microsoft announced bunch of stuff at Build 2015 keynote a few hours ago and one of them is Visual Studio Code, a free and stripped down version of Visual Studio which works on Mac OS X, Linux and Windows. It leverages bunch of existing open source software like OmniSharp, Electron. Most of all, this was my #bldwin wish :)

First of all, you should definitely install Visual Studio Code and start checking the documentation which is very extensive. I followed those steps and as I am very excited about this new tool, I wanted to share my experience thus far which is not much but very promising.

First thing I noticed was the top notch support for ASP.NET 5. The documentation for ASP.NET 5 support is pretty good but some features are not highlighted there. For example, you are getting the IntelliSense for dependencies:

Ekran Resmi 2015-04-29 19.26.46

When you add a dependency, you get nice notification telling that you should restore:

Ekran Resmi 2015-04-29 19.59.55

Pretty nice! So, how would you restore? Hit ⇧⌘P to get the command pallet up and you can see the restore command there:

Ekran Resmi 2015-04-29 21.45.20

It will run the restore inside the terminal:

Ekran Resmi 2015-04-29 21.48.30

You can also invoke your commands defined inside the project.json:

Ekran Resmi 2015-04-29 20.09.09

Ekran Resmi 2015-04-29 20.10.14

Obviously, you can change the theme.

Ekran Resmi 2015-04-29 20.18.35

Writing C# code is also very slick! You currently don’t have all the nice refactoring features you have in full fledged Visual Studio but it’s still impressive:

Ekran Resmi 2015-04-29 20.19.57

Ekran Resmi 2015-04-29 20.22.43

We even have some advanced stuff like Peek Definition:

Ekran Resmi 2015-04-29 20.02.29

Check out the documentation for all coding editor features.

As mentioned Windows is also fully supported as you might guess :)

Screenshot 2015-04-29 20.35.16

Screenshot 2015-04-29 21.18.29

Screenshot 2015-04-29 21.23.36

I want to touch on the Git integration as well. I generally use Git bash and this won’t change for me but having the diff view inside the editor in a very nice way is priceless!


How about old/current .NET applications? I managed to get one up and running easily and managed to get the build working by defining a task for that:

	"version": "0.1.0",
	// The command is tsc.
	"command": "msbuild",

	// Show the output window only if unrecognized errors occur. 
	"showOutput": "silent",
	// Under windows use tsc.exe. This ensures we don't need a shell.
	"windows": {
		"command": "C:\\Program Files (x86)\\MSBuild\\14.0\\Bin\\msbuild.exe"
	// args is the HelloWorld program to compile.
	"args": []


I was expecting this to work without any further configurations but it could be just me not being able to get it working.

As said, it’s very early but I am sold for this editor! Also, this is a fantastic time to build products on .NET platform. I would like to thank all the people at Microsoft and open source community who are making our lives easier and enjoyable. I will leave you all now and enjoy my new toy! :O

One of the new features of the Roslyn based code editor is Quick Actions. Let's see how you can use Ctlr+Enter, Enter combination instead of Ctrl+., Enter :)
@ 11-13-2014
by Tugberk Ugurlu

Visual Studio 2015 preview went public yesterday and we can enjoy the new Roslyn based code editor for C# and Visual Basic :) You can learn more about these new cool things about the code editor on Visual Studio blog.

One of the new features is something ReSharper user are very familiar with: quick actions. Sometimes inside the editor, you will see a yellow lamp popping up:

Screenshot 2014-11-13 22.14.49

This indicates that there are possible actions that you can take on this piece of code. You can bring up these actions by hitting "Ctrl+."

Screenshot 2014-11-13 22.15.54

Later, you can chose the action from the list and apply it by hitting ENTER. For very obvious stuff like the above removing unused using sample, you want to apply the action instantly. If you are using ReSharper before, I’m 99.9% sure that you will find yourself hitting "Ctrl+., ." :) as it’s easier than moving your finger from "." key to "Enter" key :) Luckily, we can come with a better keyboard shortcut for this which is "Ctrl+Enter, Enter" :)

Inside Visual Studio, go to Tools > Options:

Screenshot 2014-11-13 22.26.16

Search for keyboard and you will see the "Keyboard" section under "Environment" pane:


Search for "lineopenabove" command there which actually uses "Ctrl+ Enter" shortcut. Remove that by hitting "Remove" button:


Now, search for "quickaction" and apply the "Ctrl + Enter" shortcut as shown below:


Hoping that this will be the default at some day :) Happy "Ctrl+Enter, Enter"ing :)

Visual Studio CTP 3 has launched a while back and I was expecting to have trouble working with ASP.NET vNext beta builds. I was partially right. I wasn’t able to run the web application from Visual Studio. However, it’s still possible to debug the application and I have a workaround for you :)
@ 10-05-2014
by Tugberk Ugurlu

Today, I was working on a sample project with ASP.NET vNext. I have been working on this application without any Visual Studio IDE support but I decided to discover what Visual Studio 14 CTP 3 is bring to the table. I know that Visual Studio CTP 3 has launched a while back and I was expecting to have trouble working with ASP.NET vNext beta builds (hot from the developer machine. Find them here). I was partially right. I wasn’t able to run the web application from Visual Studio. However, it’s still possible to debug the application and I have a workaround for you :)

As I was thinking from the very beginning that I would have trouble with VS 14 CTP 3 + vNext beta builds, I started setting up my environment from the command line instead of letting the VS handle this.


However, Visual Studio still insisted on installing the Aplha3 builds of the K Runtime but anyways. That’s not big of a deal as long as I have the beta one as the active runtime. When I open up the solution, everything looked OK. Even the package restore was successful.


The build was also working. Awesome!


So, it was all going great till I realized that I was building with the OutputType set to "Class Library".


As soon as I changed it to Web Application, the build broke:


This is OK and expected as things have changed since Visual Studio 14 CTP 3 shipped. However, I’m unable to debug my application now. Hmm, not entirely. There are still options and I went with the easier one.  I switched back to command line and ran the application from there with "k web" command:


All good as you can see. Now, back to Visual Studio and press CTRL + ALT + P to bring up the Attach Process dialog box. We are looking for klr.exe to attach but you will probably see two instances of klr there. We need the one that actually hosts our application. You can find out which one is the actual host by looking at the command line arguments from the Task Manager.


In my case, it’s with the PID 1472. Finally, attach the process and you should be able to debug the application now.



Enjoy ;)

This post will show you how to you can replace the default server of OwinHost.exe with Nowin in Visual Studio 2013
@ 09-27-2013
by Tugberk Ugurlu

Wow, I cannot believe I'm writing this post :) It's really exciting to see that .NET web stack has evolved this much. First, we had a web framework shipping out of band: ASP.NET MVC. Then, we were given a chance to play with hosting agnostic web frameworks such as ASP.NET Web API and ASP.NET SignalR (I know, their names are still confusing and give an impression that those frameworks are still bound to ASP.NET but they are actually not). Recently, we have been embracing the idea of separating the application, server and the host from each other by making our applications OWIN compliant.

By this way, we can easily build our pipeline on our own and switch the underlying host or server easily. Visual Studio 2013 even has a really nice extensibility point to switch the underlying host and still have the F5 experience. OwinHost.exe is one of those hosts that we can use as an alternative to IIS. Today, we can even take this further and completely replace the underlying server (which is HttpListener by default with OwinHost.exe) by preserving the host. There is an OWIN compliant server implementation called Nowin developed by a very clever guy, Boris Letocha. This server uses a raw .NET socket to listen to the HTTP requests coming in through the wire and will respond to them. By looking at the repository's readme file, I can say that this component is not production ready but will work out just fine for demonstration purposes.

I created a mini sample application to show you this cool feature. You can find it on my GitHub OwinSamples repository, too. It only contains the following startup class and initially have two NuGet packages installed: Owin and OwinHost.

using AppFunc = Func<IDictionary<string, object>, Task>;

public class Startup
    public void Configuration(IAppBuilder app)
        app.Use(new Func<AppFunc, AppFunc>(ignoreNext => Invoke));

    public async Task Invoke(IDictionary<string, object> env)
        // retrieve the Request Data from the environment
        string path = env["owin.RequestPath"] as string;

        if (path.Equals("/", StringComparison.OrdinalIgnoreCase))
            // Prepare the message
            const string Message = "Hello World!";
            byte[] bytes = Encoding.UTF8.GetBytes(Message);

            // retrieve the Response Data from the environment
            Stream responseBody = env["owin.ResponseBody"] as Stream;
            IDictionary<string, string[]> responseHeaders = 
                env["owin.ResponseHeaders"] as IDictionary<string, string[]>;

            // write the headers, response body
            responseHeaders["Content-Type"] = new[] { "text/plain" };
            await responseBody.WriteAsync(bytes, 0, bytes.Length);

I am not sure if you have noticed this but Visual Studio 2013 even has an item template for creating an OWIN startup class:


This seems nice but it secretly installs the Microsoft.Owin package, which is unnecessary if you ask me. Owin NuGet package should be enough IMHO.

I also applied the steps explained in my "OwinHost.exe on Visual Studio 2013" post to get my application running on top of OwinHost and here is the result:


Here, my host is OwinHost.exe and it uses the Microsoft.Owin.Host.HttpListener as the server by default. At the application level, we don't need to know or care about which server we are on but most of the OWIN server implementations expose their names through the server.Capabilities dictionary:


What we want to accomplish here is to keep the host as it is and only replace the server component that it uses underneath. As our host (OwinHost.exe) is OWIN compliant, it can work with any other type of OWIN compliant server implementations and one of them is Nowin. Installing Nowin over NuGet into your project is the first step that you need to do.


However, this's not enough by itself as OwinHost.exe has no idea that we want to use Nowin as our server. Luckily, we can manipulate the arguments we pass onto OwinHost.exe. You can configure these arguments through the Web pane inside the Visual Studio Project Properties window. Besides that, OwinHost.exe accepts a few command line switches and one of them is the –s (or –-server) switch to load the specified server factory type or assembly. These are all we needed.


After saving the changes we have made, we can run the application and get the same result on top of a completely different server implementation:


Also with the same way as we did earlier, we can see that the switch has been made and Nowin is in use:


Being able to do all of this is a very big deal; especially if you think that we have been tied to IIS for very long time. I'm so happy to see .NET web stack moving towards this flexible direction.

With Visual Studio 2013 RC, we are introduced to a new extensiblity point: External Host. This gives us the F5 experience Wwth OwinHost.exe on VS 2013 and this post walks you through this feature.
@ 09-09-2013
by Tugberk Ugurlu

Since the first day I started developing software solutions for web on Visual Studio, I have had the 'F5' experience. It's nice, clean and easy to get up a web application running without digging through a specific exe file to invoke. After Cassini, our development environments have change a little with IIS Express, in a nice way of course. With the introduction of IIS Express, running it through the command line is also possible but we still have the ultimate F5 experience to get it up.

Today, we are still in love with IIS but with the introduction of OWIN, it's now much easier to build your application in an hosting agnostic way and Katana Project is providing components for hosting your application outside of IIS with a very thin wrapper on top of HttpListener. Actually, the HttpListener is one of the options in terms of receiving the HTTP request and sending back the response at the operating system level. The OwinHost.exe even abstracts that part for us. The OwinHost.exe is a very simple tool which will bring your application startup and the host layer together. Then, it will get out of your way.

However, the development environment with a custom executable tool can be very frustrating, especially in .NET ecosystem where we have really great tooling all over the place. Typically, if you would like to host your application with OwinHost.exe in your development environment, here is what you need to do:

  1. Create a class library project and install Microsoft.Owin package from MyGet ASP.NET Web Stack Nightlies feed.
  2. Add your startup class and build your pipeline with several OWIN middlewares inside the Configuration method.
  3. Add an assembly level attribute for OwinStartupAttribute to indicate your start-up class.
  4. Optionally, install the OwinHost.exe from the same feed into your project or install it any other place.
  5. Go to project properties window and navigate the "Build" pane. Change the "Output Path" from "bin\Debug\" or "bin\Release\" to "bin".
  6. Open up a command prompt window and navigate the root of your project.
  7. Execute the OwinHost.exe from the command prompt window you have just opened up and here you have the running HTTP application.

First four steps are the ones that we are OK with but the rest is generally frustrating. What we really want there is to have the F5 experience that we are used to. With Visual Studio 2013 RC, we are introduced to a new extensibility point in Visual Studio: External Host. With this feature, we are now able to replace the host layer completely. Let's see how. First, let's create a new ASP.NET Web Application:


If you are new to this "One ASP.NET" idea, this window may seem a bit awkward at first but think this as an open buffet of frameworks and modules. After selecting this, we will see the open buffet window:


For our sample application, we can continue our merry way with the empty project template without any core references. However, the Visual Studio project will still include System.Web and its related references as shown in the below picture.


Including the web.config file, we can remove all of this System.Web related stuff now to run our pure OWIN based application. In some cases, we may need web.config though as OwinHost.exe uses it for some cases such as binding redirects. After removing these junks, we have a project as seen below:


As we mentioned before, Visual Studio 2013 RC has the external host extensibility support for web applications and we can see this extensibility point by opening the Properties window of the project.


You get the IIS Express and Local IIS out of the box with Visual Studio 2013 RC (and yes, Cassini is dead for God's sake). However, it's really easy to get in there and OwinHost NuGet package has the specific installation scripts to register itself as an external host. To get this feature from OwinHost, we just need to add it into our project through NuGet. Today, OwinHost 2.0.0-rc1 package is available on and when we install the package, we get a warning popup from Visual Studio:


When we accept the integration, we can see the OwinHost showing up inside the external servers list.


If you select the OwinHost option, we can see the option which we can configure if we need to.


All these information is stored inside the project file (csproj if you are on C#):


Now, I can build my OWIN pipeline and have it running on top of OwinHost.exe just by pressing F5 inside the Visual Studio 2013. For demonstration purposes, I wrote up the following Startup class:

using Microsoft.Owin;
using Owin;
using OwinHostVsIntegrationSample;
using System.IO;

[assembly: OwinStartup(typeof(Startup))]
namespace OwinHostVsIntegrationSample
    public class Startup
        public void Configuration(IAppBuilder app) 
            app.Use(async (ctx, next) => 
                TextWriter output = ctx.Get<TextWriter>("host.TraceOutput");
                output.WriteLine("{0} {1}: {2}", 
                    ctx.Request.Scheme, ctx.Request.Method, ctx.Request.Path);

                await ctx.Response.WriteAsync("Hello world!");

When I press CTRL + F5, I have my Web application running without debugging on top of OwinHost.exe:


Very nice and elegant way of running your application with a custom server! Besides this, we can certainly run our application in debug mode and debug our OWIN pipeline. If you press F5 to run your web application in debug mode, the VS will warn you if you don't have a Web.config file:


Not sure why this is still needed but after selecting the first choice, VS will add a web.config file with the necessary configuration and we can now debug our middlewares:


Very neat. This sample I demonstrated is also available on GitHub. Enjoy the goodness :)

Hi 🙋🏻‍♂️ I'm Tugberk Ugurlu.
Coder 👨🏻‍💻, Speaker 🗣, Author 📚, Microsoft MVP 🕸, Blogger 💻, Software Engineering at Deliveroo 🍕🍜🌯, F1 fan 🏎🚀, Loves travelling 🛫🛬
Lives in Cambridge, UK 🏡