Visual Studio 2013 und 2015 : Show Line Numbers in editor / Zeilennummern im Editor anzeigen

Problem

Der Visual Studio Quellcode Editor zeigt keine Zeilennummern am linken Rand.
The Visual Studio Source Code editor is not showing line numbers on the left side.

Approach – Ansatz

Use the Tools->Options Menu to activate line numbers
Über den Menüpunkt Extras->Optionen können Sie Zeilennummern einblenden

Solution – Lösung

options

ASP.NET C#: Windows Authentication / Single Sign On

Problem

In einer ASP.NET Seite möchte man den Windows-Anmeldebenutzer ermitteln.

Ansatz / Approach

In der Web-Anwendung muss man zunächst den Haken „Enable Anonymous Access“ entfernen und einen Haken bei „Enable Windows Authentication“ setzen.

Lösung / Solution

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

/// <summary>
/// Summary description for AuthenticationService
/// </summary>
public class AuthenticationService
{
   public AuthenticationService()
   {
	//
	// TODO: Add constructor logic here
	//
   }

    public string getUsername()
    {
        string windowsLogin = System.Web.HttpContext.Current.User.Identity.Name;

        if (windowsLogin == null) return "none";

        int hasDomain = windowsLogin.IndexOf(@"\");
        if (hasDomain > 0)
        {
            windowsLogin = windowsLogin.Remove(0, hasDomain + 1);
        } //end if 

        return windowsLogin;
    }
}