我有一个asp.net mvc应用程序,其中有一个名为_GeoApi.cshtml的部分视图。
我需要在iframe中渲染它。
<iframe src='@{Html.RenderPartial("_GeoApi");}' id='fram' ></iframe> 我得到一个生成的html代码:
<iframe<script src="/Scripts/External js/jquery-1.8.2.js">
<script src="https://maps.googleapis.com/maps/api/js?key=AIzaSyBCVSBoBAUjAfb-Pfx_qq0ZKUHCitbzsl4&libraries=places&callback=initAutocomplete" async="" defer=""></script>
//content removed for brivety
src='' id='fram' />
</iframe<script>所以我需要知道
发布于 2016-03-23 21:50:34
导致错误是因为您的<script>标记中有一个<iframe>标记。
解决方案是简单地将URL作为src提供给URL,在URL中呈现部分内容,而不是尝试将内容放在iframe标记中。
<iframe src='/api/geoApi' id='fram' ></iframe> 然后创建一个具有GeoApi操作方法的GeoApi,该方法呈现"_GeoApi“部分视图。
https://stackoverflow.com/questions/36189295
复制相似问题