[英]Asp.net/Openlayers4 : Is there a chance that a map image would be exported from website without distortion and bluing?
[英]How to prevent IE8 from caching OpenLayers map data (ASP.Net)
我正在使用在C#/ ASP.Net中動態生成的KML文件處理基於OpenLayers的地圖視圖。 在文件后面的代碼中,我為KML文件調用定義了查詢字符串參數,如下所示:
/layouts/KmlDataGenerator.aspx?vaccination=2&cohort=2003%7c2010&sex=3&xaxis=Kommune&landsdel=100&show=Map&datatype=Vaccination&extendedfilters=False
這個網址字串會插入以下OpenLayers js程式碼的KmlFileName文字中:
vector = new OpenLayers.Layer.Vector("KML", {
projection: wgs84,
strategies: [new OpenLayers.Strategy.Fixed()],
isBaseLayer: false,
protocol: new OpenLayers.Protocol.HTTP({
url: '<asp:Literal ID="KmlFileName" runat="server"/>',
format: new OpenLayers.Format.KML({
extractStyles: true,
extractAttributes: true
})
})
});
問題在於IE8和更早版本似乎在緩存某些內容-我不知道到底是什么,但是除非我按CTRL + F5或手動清除IE8中的緩存,否則映射永遠不會顯示。 IE9,Firefox或Chrome中不存在此問題...
我嘗試添加元標記以防止瀏覽器緩存頁面,並且還嘗試將隨機生成的字符串添加到每個javascript調用的查詢字符串中,但是沒有任何幫助。
任何想法將不勝感激!
我在.ashx文件中出於相同目的使用了它:
public override void ProcessRequest(HttpContext context)
{
context.Response.Cache.SetNoStore();
// Execute code
context.Response.Write(<content>);
}
我在同事的幫助下解決了這個問題。 原來,要處理地圖投影的幾行JavaScript代碼必須移至document.ready()函數。 我想知道為什么只有在IE8中才需要,而在其他瀏覽器中卻沒有。 但是無論如何,它解決了問題。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.