0
我在db中使用了http://dotnetzip.codeplex.com/來壓縮的kml文件。不幸的是我的控制器發出了URL編碼的XML。何我可以阻止這一點。這裏是我的代碼:url編碼的xml文件
public void GetKMZById(int? Id)
{
try
{
if (Id == null)
{
throw new ArgumentException("No Id provided.");
}
Response.AddHeader("Content-Disposition", "attachment;filename=Map.kmz");
Response.AppendHeader("Connection", "close");
Response.ContentType = "application/vnd.google-earth.kmz";
Response.Cache.SetCacheability(System.Web.HttpCacheability.NoCache);
//Response.Charset = "utf-8";
//Response.HeaderEncoding = UnicodeEncoding.UTF8;
//Response.ContentEncoding = UnicodeEncoding.UTF8;
SearchKMZFile SearchKMZFile = SearchKMZFileRepository.Get((int)Id);
ZipOutputStream outzip = new ZipOutputStream(Response.OutputStream);
outzip.EnableZip64 = Zip64Option.Never;
outzip.CompressionLevel = Ionic.Zlib.CompressionLevel.BestCompression;
outzip.PutNextEntry("Map.kml");
XmlTextWriter xmlTW = new XmlTextWriter(outzip, Encoding.UTF8);
xmlTW.WriteString(SearchKMZFile.KMZ);
xmlTW.Flush();
outzip.Close();
}
catch (Exception e)
{
ModelState.AddModelError("Exception", e.Message);
}
}
已解壓的XML是這樣的:
<?xml version="1.0" encoding="us-ascii"?>
<kml xmlns="http://www.opengis.net/kml/2.2">
<Document>
<Style id="s">
<LineStyle>
請用四個空格縮進代碼和XML。 – SLaks 2011-03-30 15:12:49
這是** XML **轉義。 – SLaks 2011-03-30 15:15:57
如果你不允許空值,爲什麼要用'int'? – SLaks 2011-03-30 15:16:34