IOS emulator in Webview (iframe) losing the Asp.net session

Asked

Viewed 224 times

0

I have a problem with my project in Ionic, below follow the versions.

Ionic: 4.1.2
ASP.NET: 2.1.502

A little about my project...

It has a route in the application where it generates a Webview (iframe) where this webview has a module where it is possible to register and log in.

let iframe = document.createElement('iframe');
iframe.src = src;

$('page-reservations ion-content .scroll-content').html(iframe.outerHTML) 

Image of the Code
Result Image

It works in the browser (run broswer), in the apparatus (android and ios), but in specific in IOS emulator (Apple) just not working the login part.

The problem of not being able to log in was found, is that in IOS emulator is not keeping the Id da Session generated in the ASP.NET changes each request, making the user unable to access his account, remembering that this problem is occurring only in the IOS emulator (Apple), real device works normally.

Works on iPhone, works on Android Emulator, works on Browser, and the app works on Android as well.

I would like more information and to see if anyone has ever come across this situation.

  1. Is there any justification for this occurring only in the emulator IOS?
  2. Is there any way to solve this problem?

1 answer

0

Problem solved, the problem was neither in Ionic nor in ASP.NET.

What was going on? IOS emulator in Xcode it does not persist the ASP.NET session in the emulator or whenever you would log in, the Ionic application called Webview, which in this Webview would call ASP.NET API and create session and return, but in the return it already cleaned session, then never being able to access the application, this only in the IOS emulator in Xcode, used in application tests by IOS.

What was the solution? As the API existed a token in the ASP.NET session itself and it was always cleaned, so I persisted the session token in a variable in the front-end memory, remembering that it already stores this token in cookie by default, but it was cleaned by the emulator. So when sending request for API sent token together, but gave preference to cookie that already comes by default from ASP.NET, if not found used the passed in the request together, and if it did not really think the user would not be logged in.

Observing, not a good practice, but it was a problem where did learn a lot, and if they use some Webview within Ionic that needs login, persist some kind of session, maybe they will face this problem.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.