有一个旧版.net应用程序。在其内容页面中,我需要打开一个MVC应用程序。所以我正在使用Iframe并打开MVC应用程序。
我对如何通过自定义标头将参数发送到MVC应用程序感到困惑。我不能使用查询字符串,因为需要发送的参数很大。
请帮助。
<asp:Content ID="Content" ContentPlaceHolderID="MainContent" runat="server">
<iframe id="frame" ></iframe>
</asp:Content>
这是我的.net应用程序中的代码。调用MVC appl时如何添加标头。
不知道通过“自定义标头”传递数据是什么意思。通常,标头用于元数据,而不是数据。如果您要传递大量数据,则传统方式是通过表单/发布。这是一种实现方法:
在旧版应用程序(包含iFrame的应用程序)中:
<asp:Content ID="Content" ContentPlaceHolderID="MainContent" runat="server">
<iframe id="frame" src="https://MyLegacyApp.com/Handoff.aspx"></iframe>
</asp:Content>
注意:是的,iFrame的SRC指向旧版应用程序,而不是新的MVC应用程序。
将一个新页面添加到名为的旧版应用中Handoff.aspx
,如下所示:
<!-- Provide image while form is posting. Style = centered. -->
<IMG SRC="Spinner.png" ALT="Please wait" style="position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%);">
<!-- Hidden form that will post data to MVC site -->
<FORM Action="https://MyMVCApp.com/ReceiveHandoff" method="POST">
<INPUT Name="Input1" Type="Hidden" Value="PLACE YOUR HUGE DATA HERE, OR IN SEVERAL HIDDEN TAGS IF YOU WANT.">
</FORM>
<!-- Script that autoposts the form -->
<SCRIPT>
window.onload = function(){document.forms[0].submit();}
</SCRIPT>
现在,您的MVC网站中的“ ReceiveHandoff”页面将通过iFrame进行访问,并使用表单中传递的数据进行初始化。要读取数据,可以使用以下方法之一,例如:
var data = Request["Input1"];
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句