LTI Advantage Resource Link not opening in Iframe

I have struggled with this issue for a couple of days and I could not find any solution.

I have implemented LTI Advantage (LTI 1.3) and it works like charm. However there is one issue that I am not able to get rid of. In LTI 1.3 we have an option of displaying the tool's content in an iframe (There is also an option of displaying it in a window but I want to stick to IFrame only)

When I try to create a deep-link it opens in iframe as expected. However when I try to open a resource link, the application is opened in a new window instead of an iframe.

I searched for a possible solution : I thought it must be because of X-Frame-Options appended in the response header, I tried to remove it manually by adding code in Global.aspx.cs I have written code to remove this header from web config settings but nothing worked.

Now I am wondering my code to launch application could be the culprit. I am launching application using form post using the following code:

string content = string.Empty;

content += "<html><head></head>";
content += string.Format("<body onload=\"document.{0}.submit();\">", "newForm");
content += "<form name=\"newForm\" target='_parent' method=\"POST\" action=\"" + fadavisLtiUrl + "\">";
foreach (var item in ltiRequestData)
{
content += string.Format("<input type=hidden name=\"{0}\"value=\"{1}\">", item.Key, item.Value);
}
content += "</form>";
content += "</body></html>";
return Content(content);

Is this code responsible for launching the application in the window instead of iframe?

THE same LMS settings work for my other POC application without any problem. However the only difference is my launchable application was just a test page in the same domain in the same POC application. Whereas in real-time scenarios it is the different application with a slight difference in URL.

Here are some sample URLs I am using.

OIDC Login Validation URL: https://mysiteltiadvantage.mysite.com/ LTI App Launch URL: https://devtesting.mysite.com/LTI/home/LTIAdvantageApp?productid=13902 Application URL: http://apptest.mysite.com/product?applicationid=13&accountid=1076615

Can anybody suggest any workaround to open the application in IFrame withing LMS or point the mistake I am doing here?

Laxman Mankala.

Thanks in Advance.