Configure DNS Aliases in IISExpress for localhost

A direction we are taking Process PA is white labelling for our partners. To do this we are still hosting on the same scalable platform on Microsoft Azure and essentially adding another level of multi-tenanting in our codebase. When a user navigates to https://app.processpa.com/ they will get our first party branded experience. However, when a user navigates to something like https://partner1.processpa.com, they will get a tailored experience complete with branding, different resources, templates and features specific for those customers supported by our partners.

Building out the experience using Dependency Injection with Branch By Abstraction based on the host is reasonably straight forward. I however wanted the local development environment to be run in the same way, rather than switching in code for whatever partner experience was being built out at the time. To do this I need to be able to configure local DNS records for localhost and IISExpress. The answer I found on StackOverflow but below are the simplest steps that worked for me.

  1. Open Notepad as an Administrator
  2. Open in Notepad C:\Windows\System32\drivers\etc\hosts
  3. Copy the comment lines for localhost host and add as your DNS records
    127.0.0.1    partner1.localhost
    ::1          partner1.localhost
  4. For Visual Studio 2015, open <Solution folder>\.vs\config\applicationhost.config
  5. Find the site and add the bindings you need, making sure to change the ports.
    <bindings>
    <binding protocol="http" bindingInformation="*:1704:localhost" />
    <binding protocol="https" bindingInformation="*:44300:localhost" />
    <binding protocol="http" bindingInformation="*:1705:partner1.localhost" />
    <binding protocol="https" bindingInformation="*:44308:partner1.localhost" />
    </bindings>
  6. To prevent the need to run Visual Studio as admin to start IISExpress on those ports, open an Administrator command prompt and run:
    netsh http add urlacl url=http://partner1.localhost:1705/ user=machine\username
    netsh http add urlacl url=https://partner1.localhost:44308/ user=machine\username

If you have certificate trust issues check out: https://blogs.msdn.microsoft.com/robert_mcmurray/2013/11/15/how-to-trust-the-iis-express-self-signed-certificate/.

And that’s it! When you go to https://localhost:44300 or https://partner1.localhost:44308 you get the same application with a different experience.

Advertisements

Visual Studio Debugger Failing to inspect variables

Everything compiled fine and the app is running well. However when I attached the debugger to w3wp.exe and however over variables, no value was being shown. Ctrl-Alt-Q on one for Quick Watch revealed the problem.

error CS1704: An assembly with the same simple name ‘###’ has already been imported. Try removing one of the references (e.g. ###.dll) or sign them to enable side-by-side.

Error seems straight forward enough. Help points to fixing references as the error would suggest. This only just started happening. And not just me. So it must be a code change right? Looking through version history, everything looks innocent. I check the references and they are all fine. So I must have some messed up assemblies somewhere.

Rebuild.

Clean. Build.

Clean entire workspace. tfpt treeclean

Restart visual studio.

Rise & Repeat…

No avail. Both my git and TFVC workspaces have the same problem.

Reboot computer in case of cache.

Then I delete the Temporary ASP.NET Files for the web site in C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files.

Bingo! Some change must have caused a duplicate to be place in there somehow. Not the best resolution, but as least I can inspect the code with the debugger again.

Debug Lambda Expression–Delivered!

Way back in July 19, 2011 I added on the, then relatively new, Visual Studio User Voice page Debug Lambda expression feature request. It quickly gain many votes and was sitting in the top few all this time. Microsoft stated that this was a hard thing to do requiring a complete rewrite of their Expression Evaluator. Instead of just saying it was too hard and not important enough, they did get to work. It is available now in Visual Studio 2015 Preview. Full details are given in the Support for Debugging Lambda Expressions with Visual Studio 2015 on the Visual Studio ALM blog.

 

Debug Lambda expressions [UserVoice]

It has been a long time coming. But I for one am very happy it has come. Well done Microsoft and all who were involved.

Visual Studio 2013 Cookbook Review

Disclaimer: I was provided a complimentary electronic copy of this book by the publisher. In no way was I directed on the content of my review. Opinions are mine alone.

Why would you buy a Visual Studio 2013 book instead of just using the Internet to find what you need? Simple, time and content. The amount of new features and ways to do things in this version is substantial. Mining the Internet you are sure to miss many gems that could make a large difference to your day-to-day work. Going through this book you will benefit that a team of people has done the work for you. Ensuring they have included everything and the content is correct for your easy perusal.

  • Chapter 1 gives a very good overview of the new additions to the main tool you use each day.
  • Chapter 2 gives a very good starting place for Windows 8.1 development. It will get you past the new stuff quickly to allow you to get into the code.
  • Chapter 3 goes over Web Development with MVC 5 and the new One ASP.NET model.
  • Chapter 4 uses some I’m not dead yet WPF ("WPF remains the recommended choice for developing desktop applications on the Windows platform. Visual Studio 2013 itself is a WPF application", p 118) WF, WCF and .NET application development.
  • Chapter 5 Debugging Enhancements
  • Chapter 6 Asynchrony in .NET
  • Chapter 7 C++, I skimmed this one, but the C++ developer should be thrilled, and it makes me want to learn DirectX.
  • Chapter 8 Team Foundation Server features from a users perspective. Great features that many developers aren’t utilizing that can very much help day-to-day. If you are managing a TFS server though, you’ll want more than what is provided here.
  • Chapter 9 is on languages TypeScript, Python and IronPython. TypeScript I knew and understand, but I have no idea about Python, and don’t really want to, but it’s good to know it’s available if that’s your flavour of choice.
  • Appendix contains recipes on Installers, Submitting Windows Store apps, Visual Studio Add-ins and extensions, and creating your own snippets.

The "There’s more…" sections littered throughout are valuable on there own, revealing many power user features I was unaware of. The recipe format of the books make it a great reference to have on-hand. Going to the relevant recipe within the book will be a faster and more reliable process than going online.

I intended to flick through this book quickly and dive in on a couple of chapters. I however could not help but go through it all. The capabilities we have available to us, just from Visual Studio is amazing. Going over it all I can’t help but think of all the possibilities and opportunities. Now I must get back to coding.

If you want to get a hold of this book you can get it directly from the publisher, Amazon and many retailers.

Technorati Tags:

Web Test playback does not use concurrent requests as recorded

I have been running performance tests using Visual Studio Web Tests and Load testing. The goal has been to prove the raw load time and the scalability under increasing users. The web test recorder is quite good for simple request-replay. However, beware a bunch of work is required to parse previous requests for keys to be passed back in subsequent requests, especially for more complex web applications but not as much on simple web sites.

Here’s the results for the single user playback with requests grouped into relevant transactions that we needed to measure.

Web Test results

The odd thing that was happening though is that when we were timing the action Open Report with a stopwatch manually in the browser we were getting typically getting under 5 seconds for completion. The reason for the difference became clear when you watch the web test running. You will see each request going sequentially. If you compare it to the timing from the browser, the actually running is not like that. Below is the timings column from network monitoring from the browser. The two highlighted rows are the requests that take the longest amount of time, but are run together.

Browser Timings

Adding up these request sequentially gets us to similar total time as to what the web test replay presented. So to make the request parallel in the web test you need to set the requests as dependent requests to the first. Right-click the request and select Add Dependent Request.

image

This will add http://localhost/. Delete that request after you have drag-and-dropped the requests that you want to run concurrently into the Dependent Requests folder.

image

Rerunning the web test after this change resulted in timings much like what we experienced manually.

Improved Web Test results

Other things to look for is that Think Times are not on and set to 0 for all requests and turn on cache control for all requests.

Update: So when does the web test recorder get the dependent requests correct? Taking into account the Initiator column in the Network tab of the development tools made it clear:

Initiator

These link and script tags are by default dependent requests for the page.

image

These XMLHttpRequest JavaScript calls are not seen by the web test recording as running in parallel and need to be manually be put in as dependent requests as above.

Technorati Tags:

Visual Studio 2013 Project Load Error – The parameter is incorrect or Unspecified error

Here we have this nice obscure error message from Visual Studio 2013. I get it for almost all my projects within the solution, which at 23 or 67 that’s no fun.

image

If a project is reloading due to a background update and you click Reload, then you might get this other unhelpful message.

image

The strange part is that it would go away and then come back. What we discovered is that it is a bug due to the source control bindings on the solution mismatching the connection settings in Team Explorer. In our case we have multiple URLs that resolve to our TFS server. In our solution file we have http://tfs:8080/tfs/<projectcollection&gt; yet in my connection I have https://tfs.<domain&gt;.com/tfs/<projectcollection>. After going through all the error dialogs if you Save All to save the solution file and do a diff, you will see all the URLs updated to your connection.

image

After making sure all the source control paths are the same in all your solution files, ensure everyone on the team updates their TFS connection, by creating a new connection to the desired address.

  1. image
  2. image
  3. image
  4. image
  5. image

You don’t need to remove the existing one, although, it is advised so that you are sure to connect to the correct address.

Failure of Search TFS

Well over a year ago I set up a landing page to start gathering emails for interest in Search TFS. A dynamic integrated TFS work item search experience. Today I am calling an end to the project. Although the project didn’t go anywhere, by the process I followed I wasted little time and could fully justify the position the product was to take. The main reason to kill it is that Visual Studio 11 is shipping with integrated TFS work item searching. Finally.

Team Explorer VS11 Search

I think this helps justify that there is a need for what I wanted to do. The existing Search Work Items for TFS 2010 had 7,076 downloads on the 1st January 2011 when I was starting this and now has, 23,093. That’s not a bad niche. How many would be willing to pay for something better is another question. On my landing page, I got 12 emails. Considering that there was absolutely no push, SEO, linking (apart from this blog) or advertising I’m happy there was something and I have a baseline.

Soon after I launched the landing page I got wind the Microsoft was finally going to do something. So I waited to see. Now that I’ve been playing with Visual Studio 11, I’m happy with the new Team Explorer for the most part, but I was quite disappointed with the search. It’s no better that the current available plug-in. That means it’s slow and query based. I wanted more like OneNote, where you see results as you start typing:

OneNote Search

The market though, even for something substantially better I feel is drastically reduced now that it is first party. I’m disappointed Microsoft didn’t do better since search is one of the most important features of work item tracking. The way that UserVoice does it to help prevent duplicates is brilliant. I’m hoping the search works better with TFS 11 but  since running it against Team Foundation Services (fantastic btw, especially the just announce build service) I have little hope for that.

All is not lost. TFS Working On has improved in its download rate. ClickOnce deployment having less friction may have helped that. It’s long overdue for an overhaul. I’ve had plans for nice Windows 7 integration for a long time, now I should be looking at Windows 8 perhaps. Search TFS will still fit nicely into TFS Working On, especially for those that don’t live in Visual Studio.