title: Display special characters
body: <pre><code>@{
      Layout = null;
      string root = Server.MapPath("~");
      string path = @"Content\galleries\galleries\";
      DirectoryInfo Dir = new DirectoryInfo(root + path + (string)ViewData["Name"]);
      FileInfo[] FileList = Dir.GetFiles("*.jpg");
      string response = "";
  }
  
  &lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
  &lt;html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"&gt;
  &lt;head&gt;
      &lt;script type="text/javascript"&gt;
          jQuery(function ($) {
  
              var array = new Array();
              var galleryname = '@ViewData["Name"]';
  
              @for (int i = 0; i &lt; FileList.Length; i++)
              {
                  string s = @"
                  var path = '../Content/galleries/galleries/" + @ViewData["Name"] + @"/" + @FileList[i].Name + @"';
                  var thumbpath = '../Content/galleries/galleries/" + @ViewData["Name"] + @"/thumbs/" + @FileList[i].Name + @"';
                  array[" + i.ToString() + @"] =
                      {
                          image: path,
                          title: '" + @ViewData["Name"] + @"',
                          thumb: thumbpath,
                          url: path
                      };";
                  response += s;
              }
              @response
  </code></pre>
  
  <p>This is my code. I want to dynamically write some javascript code with asp.net. When I print the string 'response' with @response , in page source I can see than all ' characters are changed to &amp; #39; . All paths are bad then. I also tried using Response.Write(s) inside the loop, and ' characters are not changed, but then generated code is placed in the very beginning of the page source, before doctype and of course, nothing works.</p>
  
  <p>How to resolve these issues? Or at least one of them  ;) ? Or is there another way?</p>