問題描述
如何從 php wordpress 服務器呈現 aspx 頁面 (How to render an aspx page from a php wordpress server)
I would like to have a page on our wordpress server to render an aspx page from a .net server that we have. Is there a good way to handle this using jquery or some other php library?
I need to do this, because aspx is able to pull data from sql server and I want our web designer to properly present this data using wordpress server.
‑‑‑‑‑
參考解法
方法 1:
If the .NET server is not part of the same domain as the WordPress server, your best approach would be to use an iframe instead
<iframe src="http://url/to/.net/server.aspx">
</iframe
jQuery may also help provided both, the .NET server and the WordPress server are in the same domain.
You could do something like this with jQuery:
$(function(){
$('#result').load('http://google.com');
});
And simply have a div in your wordpress server with id result
, as in:
<div id="result" >
</div>
方法 2:
You want to render the apsx page in a Wordpress page? You also might define a shortcode in wordpress. This should handle embedding the content server side (could use optimization, caching):
# shortcode [embedcontent href="http://www.yoursite.com/page.aspx"]
function embedcontent($atts, $content = null) {
if ( isset( $atts['href'] ) ) {
return file_get_contents( $atts['href'] );
}
return '';
}
add_shortcode("embedcontent", "embedcontent");
Otherwise, js does have some restrictions accessing content cross‑domains.
(by Max Marchevsky、Icarus、Kevin Seifert)