Note that there are some explanatory texts on larger screens.

plurals
  1. POHttpContext.Current.User.Identity.Name is empty using IIS Express but not Visual Studio Development Server
    primarykey
    data
    text
    <p><code>HttpContext.Current.User.Identity.Name</code> is empty/blank when Visual Studio is set to "Use Local IIS Web server" but works correctly when Visual Studio is set to "Use Visual Studio Development Server".</p> <p>Hopefully you can duplicate this problem in Visual Studio 2010 or 2012 (I have tried both) by doing the following:</p> <p>Create a new "ASP.NET Empty Web Application" with ".NET Framework 4" selected and name it "WindowsAuthTest2". Replace the contents of Web.config with</p> <pre><code>&lt;?xml version="1.0"?&gt; &lt;configuration&gt; &lt;system.web&gt; &lt;compilation debug="true" targetFramework="4.0" /&gt; &lt;authentication mode="Windows"&gt; &lt;/authentication&gt; &lt;/system.web&gt; &lt;/configuration&gt; </code></pre> <p>Next add a new "Web Form" to the project called "Default.aspx". Replace the code in Default.aspx with</p> <pre><code>&lt;%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="WindowsAuthTest2.Default" %&gt; &lt;html&gt; &lt;head&gt; &lt;title&gt;&lt;/title&gt; &lt;/head&gt; &lt;body&gt; &lt;asp:Label ID="Label1" runat="server"&gt;&lt;/asp:Label&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>And replace the code in Default.aspx.cs with</p> <pre><code>using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; namespace WindowsAuthTest2 { public partial class Default : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { Label1.Text = "[" + HttpContext.Current.User.Identity.Name + "]"; } } } </code></pre> <p>I don't have ReSharper to tell me which of those using statements are unnecessary.</p> <p>Then you can select which web server Visual Studio will use by right-clicking the project, selecting "Properties" (or by double clicking "Properties" under the project), selecting "Web", and navigating to the "Servers" section.</p> <p>Try it with "Use Visual Studio Development Server" and "Use Local IIS Web server".</p> <p>Hopefully you can help me figure out why <code>HttpContext.Current.User.Identity.Name</code> is empty when "Use Local IIS Web server" is selected.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload