我有一个在asp.net框架上使用SVG坐标的网页。
通过试用错误,如果我拿出大部分标签,我收到没有错误。但是如果我的所有标签都出现了以下错误
Compiler Error Message: CS8095: Length of String constant exceeds current memory limit. Try splitting the string into multiple constants.
Line 195: private global::System.Web.UI.LiteralControl @__BuildControl__control2() {
Line 196: global::System.Web.UI.LiteralControl @__ctrl;
Line 197: @__ctrl = new global::System.Web.UI.LiteralControl("\r\n\r\n \r\n<div class=\"row\">\r\n <div class=\"col-xs-24 banner section\">\r\n " +
Line 198: "<div class=\"row\">\r\n<div class=\"col-xs-24 col-sm-14 map-container\"> <!-- MICHAEL:" +
Line 199: " be sure to add the class \'map-container\', this is for the tooltip location -->\r" +
源代码是
<div class="col-xs-24 col-sm-14 map-container"> <!-- MICHAEL: be sure to add the class 'map-container', this is for the tooltip location -->
<!-- <img class="map" src="images/map.svg" width="100%"> -->
<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 18.1.1, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
viewBox="0 230.5 613.3 331" enable-background="new 0 230.5 613.3 331" xml:space="preserve">
<g>
<polygon fill="#FFFFFF" points="609.6,301.2 609.4,301.1 609.3,301.1 609.1,301 609,300.9 608.8,300.8 608.6,300.7 608.5,300.6
608.4,300.4 608.3,300.3 608.2,300.1 608.1,299.9 608.1,299.8 608,299.6 608,299.4 608,299.2 608,299 608,298.9 608.1,298.7
608.1,298.4 608.2,298.3 608.3,298.1 608.4,298 608.5,297.9 608.6,297.7 608.8,297.6 609,297.5 609.1,297.4 609.3,297.3
609.4,297.3 609.6,297.2 609.8,297.2 610,297.2 610.2,297.2 610.4,297.2 610.5,297.3 610.8,297.3 610.9,297.4 611.1,297.5
611.2,297.6 611.4,297.7 611.5,297.9 611.6,298 611.7,298.1 611.8,298.3 611.9,298.4 611.9,298.7 612,298.9 612,299 612,299.2
612,299.4 612,299.6 611.9,299.8 611.9,299.9 611.8,300.1 611.7,300.3 611.6,300.4 611.5,300.6 611.4,300.7 611.2,300.8
611.1,300.9 610.9,301 610.8,301.1 610.5,301.1 610.4,301.2 610.2,301.2 610,301.2 609.8,301.2 "/>
<polygon fill="#FFFFFF" points="601.2,301.1 601.3,301 601.4,300.8 601.5,300.7 601.7,300.6 601.9,300.5 601.9,300.5 602.1,300.4
602.2,300.4 602.4,300.3 602.6,300.3 602.7,300.3 602.8,300.3 602.9,300.3 603.1,300.3 603.4,300.4 603.5,300.4 603.6,300.5
603.8,300.6 604,300.7 604.2,300.8 604.3,301 604.3,301.1 604.5,301.2 604.6,301.4 604.6,301.5 604.7,301.8 604.8,301.9
604.8,302.1 604.8,302.4 604.8,302.5 604.8,302.7 604.7,302.9 604.6,303 604.6,303.2 604.5,303.3 604.3,303.5 604.3,303.7
604.2,303.8 604,303.9 603.8,304 603.6,304.1 603.5,304.2 603.4,304.2 603.1,304.3 602.9,304.3 602.8,304.3 602.6,304.3
602.4,304.3 602.2,304.2 602.1,304.2 601.9,304.1 601.7,304 601.5,303.9 601.4,303.8 601.3,303.7 601.2,303.5 601.1,303.3
601,303.2 600.9,303 600.8,302.9 600.8,302.7 600.8,302.5 600.8,302.4 600.8,302.1 600.8,301.9 600.8,301.8 600.9,301.5 601,301.4
601.1,301.2 "/>
+8000多行
我该怎么办?我需要使用元素标签,因为使用jquery我会发生这些标签的事件。所以我不能指向该文件。我需要所有的
更新我将内联多边形标签降低到1行898kb,我注意到VSBComplier.exe(类似的东西)占用了我所有的RAM并使浏览器崩溃。
为了调试,仍然必须将svg放在评论中。
答案 0 :(得分:1)
THe issue was iisexpress vs iis.exe w3p.exe. This only happens on my local computer
in debug it gives this error.
Putting it on a production server, the error does not happen
Hopefully this thread serves a purpose. Even though my computer has plenty of RAM and space.
答案 1 :(得分:0)
How about separating your very long string constant into several chunks and have them all in a List<String>
Also, consider using single-page-application approach where you make an ajax call to the web server which will directly return the SVG data and then display the SVG data using client side programming such as JQuery. This will avoid having to render things server-side in ASP.NET MVC's views.
答案 2 :(得分:0)
Just a shot in the dark here, by why not load the SVG via CSS?