StringBuilder html = new StringBuilder();
string jqueryPath = System.IO.Path.Combine(appPath, "jquery-1.7.2.js");
Pretty standard stuff, right? Well, actually, no.
When I navigated to my html stream, I received the error "invalid character at line 1 character 1". If I saved the stream to a HTML file, and loaded it in IE (v9), it worked fine (no error).
The problem is related to security for locally loaded files (if you want to google it, be my guest), and there are three fixes available (that I could find):
- Add "about:blank" to your Trusted Sites in IE (we couldn't do this because it added one more moving part to the deployment process of the app, and probably compromises security in some as-yet-to-be-determined manner.
- Create a blank HTML file, load it, and modify the DOM by inserting script elements programatically . We didn't want to do this because there was a possibility we'd forget to add something, and this code also has to eventually be cross-platform.
- Just bite the bullet and add the script file content as text in the string. This meant we'd have to load the file ourselves, and insert it into the
We chose the third option. It was the easiest and posed the fewest possible problems. Your mileage may vary.
I've been paid as a programmer since 1982 with experience in Pascal, and C++ (both self-taught), and began writing Windows programs in 1991 using Visual C++ and MFC. In the 2nd half of 2007, I started writing C# Windows Forms and ASP.Net applications, and have since done WPF, Silverlight, WCF, web services, and Windows services.
My weakest point is that my moments of clarity are too brief to hold a meaningful conversation that requires more than 30 seconds to complete. Thankfully, grunts of agreement are all that is required to conduct most discussions without committing to any particular belief system.