title: Login not working on IFrame in VB.NET MVC application
body: <p>I have a vb.net mvc application. Everything on site works fine. However, i am unable to login when i try to login through IFrame. </p>
  
  <p>When i debug it, the login function does return true but it's not logging in. </p>
  
  <p>I am using partial in the log in page. </p>
  
  <pre><code>  &lt;div id="rightCol" class="rightCol"&gt;
          @If Model.ShowLogonPanel = True Then
              If Model.Broker.Network.Id = 46 Then
                  @&lt;strong&gt;@Html.Label("WhitelabelLoginLabel", "Existing customers log in here.", cultureDetail)&lt;/strong&gt;
              Else
                  @Html.label("BrokerLoginLabel", "Access saved quotes and service your client's policies online", cultureDetail)
              End If
          End If
          &lt;div id="rightCol1" class="rightCol1"&gt;
              @If Model.ShowLogonPanel = True Then
                  @&lt;div id="rightCol1a" class="rightCol1a" style="color:#@Model.PanelTextColor;background-color:#@Model.PanelBackgroundColor"&gt;
                  &lt;fieldset&gt;
                      @If Model.Broker.Network.Id = 46 Then
                          @Html.Legend("Existing Customers", cultureDetail)
                      Else
                          @Html.Legend("Broker Login", cultureDetail)
                      End If
                      &lt;div style="margin-top:-10px;width:150px;vertical-align:middle;color:#@Model.PanelTextColor;background-color:#@Model.PanelBackgroundColor"&gt;
                          @Using Html.BeginForm()                       
                              @Html.Partial("_SignIn", New GPM.QuickQuote.Domain.SignInViewModel)
                          End Using
                          &lt;div style="color:Red;font-size:1.20em;margin-left:-22px;width:176px;font-weight:bold;text-align:center;background-color:#@Model.PanelBackgroundColor"&gt;
                              &lt;strong&gt;@Html.ValidationMessage("SignInError")&lt;/strong&gt;
                          &lt;/div&gt;
                      &lt;/div&gt;
                      &lt;/fieldset&gt;  
                  &lt;/div&gt;
              End If
          &lt;/div&gt;
          &lt;div id="rightCol2" class="rightCol2" &gt;
              @If Model.ShowNeedHelpPanel = True Then
                  @&lt;div id="rightCol2a" class="rightCol2a" style="color:#@Model.PanelTextColor;background-color:#@Model.PanelBackgroundColor"&gt;
                  &lt;fieldset style="width:86%"&gt;
                      &lt;legend style="text-align:center"&gt;@Html.Raw("WhiteLabels", "NeedHelpTitle", Model.Id, Model.NeedHelpTitle, cultureDetail)&lt;/legend&gt;
                      &lt;div style="text-align:center; margin-top:-10px;margin-left:-10px; margin-right:-10px;color:#@Model.PanelTextColor;background-color:#@Model.PanelBackgroundColor"&gt;
                          &lt;label id="NeedHelp" style="text-align:center;margin-top:-20px"&gt;@Html.Raw("WhiteLabels", "NeedHelpText", Model.Id, Model.NeedHelpText, cultureDetail)&lt;/label&gt;
                          &lt;a id="NeedHelpEmail" style="display:inline-block;margin-left:-23px; margin-right:-23px" href="mailto:@Html.Raw(Model.NeedHelpEmail)?subject=Online Help"&gt;@Html.Raw(Model.NeedHelpEmail)&lt;/a&gt;
                      &lt;/div&gt;
                  &lt;/fieldset&gt;
                  &lt;/div&gt;
              End If
          &lt;/div&gt;       
          &lt;div id="rightCol3" class="rightCol3"&gt;
              @If Model.ShowBespokePanel = True Then
                  @&lt;div id="rightCol3a" class="rightCol3a" style="color:#@Model.PanelTextColor;background-color:#@Model.PanelBackgroundColor"&gt;
                  &lt;fieldset&gt;
                      &lt;legend style="text-align:center"&gt;@Html.Raw("WhiteLabels", "BespokePanelTitle", Model.Id, Model.BespokePanelTitle, cultureDetail)&lt;/legend&gt;
                      &lt;div style="margin-top:-10px;color:#@Model.PanelTextColor;background-color:#@Model.PanelBackgroundColor"&gt;
                          &lt;label id="BespokePanel" style="margin-top:-20px"&gt;@Html.Raw("WhiteLabels", "BespokePanelText", Model.Id, Model.BespokePanelText, cultureDetail)&lt;/label&gt;        
                      &lt;/div&gt; 
                  &lt;/fieldset&gt; 
                  &lt;/div&gt;
              End If
              &lt;/div&gt;   
          &lt;/div&gt;
  
  
  </code></pre>
  
  <p>Code for Sign In:</p>
  
  <pre><code> Public Sub SignIn(ByVal login As ILogin, ByVal whiteLabelId As Integer, ByVal createPersistentCookie As Boolean) Implements IAuthenticationService.SignIn
  
          SessionService.WhiteLabelId = whiteLabelId
  
          Dim authenticationTicket = New FormsAuthenticationTicket("1", login.Id.ToString + "," + login.Email, DateTime.Now, DateTime.Now.AddMinutes(60), createPersistentCookie, login.SeperatedLevelIds(","), "/")
          Dim cookie = New HttpCookie(FormsAuthentication.FormsCookieName, FormsAuthentication.Encrypt(authenticationTicket))
  
          If authenticationTicket.IsPersistent Then
              cookie.Expires = authenticationTicket.Expiration
          End If
  
          HttpContext.Current.Response.Cookies.Add(cookie)
  
  
      End Sub
  </code></pre>
  
  <p>I have a SessionService class that assigns the value to session. On debugging, i realized that it is assigning the values correctly. But when it comes to get the value. It doesn't have the value in it when using Iframe. </p>
  
  <pre><code>Public Class SessionService
  
  
     Public Shared Property WhiteLabelId() As Integer
         Get
             Return HttpContext.Current.Session("WhiteLabelId")
         End Get
         Set(ByVal value As Integer)
             HttpContext.Current.Session("WhiteLabelId") = value
         End Set
     End Property
  
     Public Shared Property QuestionSetId() As Integer
         Get
             Return HttpContext.Current.Session("QuestionSetId")
         End Get
         Set(ByVal value As Integer)
             HttpContext.Current.Session("QuestionSetId") = value
         End Set
     End Property
  
  </code></pre>
  
  <p>For example, the whiteLabelId in the code above is assigned the correct value. But it doesn't save that in the session in Iframe. </p>
  
  <p>Not sure, if it's the session issue as i explained above. Cookies issue or the certificate issue. I have tried it on Chrome, Firefox, IE, Opera. </p>
  
  <p>If there's something i can do with my IFrame to make it work ? </p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
  &lt;head&gt;
      &lt;meta http-equiv="X-UA-Compatible" content="IE=Edge" /&gt;
  &lt;/head&gt;
  &lt;body&gt;
  
  &lt;iframe src="http://example.com/" width="1000" height="1000"&gt;
  &lt;p&gt;Your browser does not support iframes.&lt;/p&gt;
  &lt;/iframe&gt;
  
  &lt;/body&gt;
  &lt;/html&gt;
  
  </code></pre>
  
  <p>Please help. </p>
  
  <p>Thanks.</p>