Server Side Includes for HTML - html

How do I enable Server Side Includes for html file hosted on IIS 8.5? Like:
<!--#include virtual="filename.htm"-->
Currently, I don't see include file (html) content when I open page in browser.
Edit: I manually added module mapping of ServerSideIncludeModule for website & still doesn't work.

You have the correct module mapping handler.
When you add the module mapping under Handler Mapping in IIS 8.5 double check that you specify *.html as the file type; don't forget the asterisk (the *). I had added it only as .html, and that won't work.
Also, when you add the module mapping, make sure you click on the "Request Restrictions..." button; on the Mapping tab for restrictions, the checkbox for "Invoke handler only if request is mapped to:" should be checked, and the selection should be set to File. More importantly, on the Verbs tab for the restriction, make sure that the lower dot is selected for "One of the following verbs:" and in the field below you should have "GET, HEAD, POST". Lastly, on the Access tab you should have "Script" selected.
Lastly, if you haven't done the appcmd.exe to set ssiDisable to false, you'll need to run this at at command prompt (run the command prompt as Admin).
cd %windir%\system32\inetsrv
appcmd.exe set config "Name_of_website_as_it_appears_in_IIS_Manager" -section:system.webServer/serverSideInclude /ssiExecDisable:"False" /commit:apphost

Related

In AppleScript and BBEdit how can you check links?

In BBEdit there is the command under Markup -> Check -> Document Links shortcut cmd+control+k that checks all links. When I look at the dictionary under BBEdit > HTML Scripting -> check links it shows:
but when I try to script against a project with:
set theResult to check links of active document of project window 1
I get an Error of item, when I try to check based on the filename with:
set foobar to (name of active document of project window 1) as string
set theResult to check links of foobar
I still get the same error, if I try:
set projectPath to file of project document 1
set theResult to check links of projectPath
I get a returned of {}. Thinking it was an issue with not adding with show results I changed it to:
set theResult to check links of projectPath with show results
but I get a return of activate
When I search through Google I'm unable to find a solution on if it's possible to return a boolean on wether the links in the HTML file are valid when scripting through the content. So my question is, how can I get AppleScript to tell me the links are valid in BBEdit with check links?
To check the links from the file of the active document:
tell application "BBEdit"
set theFilePathOfFrontProject to file of text document 1 -- get the path of the selected file in the front project window
set theResult to (check links of theFilePathOfFrontProject) is {}
if theResult then
display dialog "All links appear to be valid"
else
display dialog "Some links appear to be not valid"
end if
end tell
Informations :
set projectPath to file of project document 1, this command return the path of the project (check links on this file will always return an empty list), the path will be file "fullpath:someName.bbprojectd", it's not the path of the selected HTML file in the project.
To get path of all files of the project : set allFilePaths to project collections of project document 1 -- list of paths
I believe this worked last time I used it, I'm on mobile about to board a flight so syntax may have gotten mumbled.
set theFile to ((path to documents folder) as string) & "test.html"
set theResult to check links of file theFile
To use system events to press keys, you could use a separate tell block, or create a handler like so.
on checkLinks()
tell application "System Events"
keystroke "k" using {command down, control down}
end tell
end checkLinks
then call the handler as usual
my checkLinks()

Why does my file download link seem to work, but is unable to find the file?

I added this HTML to a page that I render via a REST call:
StringBuilder builder = new StringBuilder();
. . .
builder.Append("<p></p>");
builder.Append("<a href=\"/App_Data/MinimalSpreadsheetLight.xlsx\" download>");
builder.Append("<p></p>");
. . .
return builder.ToString();
My ASP.NET Web API project has a folder named "App_Data" which does contain a file named "MinimalSpreadsheetLight.xlsx"
The download link is indeed rendered on the page, and clicking it does appear, at first, to download the file (it has the Excel icon, and it bears the file name), but beneath that it says "Failed - No file":
Is the problem with my HTML, or the path I'm using, or file permissions, or what?
I've only tested this with Chrome, so far, BTW. IOW, it's not an IE issue.
UPDATE
I tried it with a leading squiggly, too:
builder.Append("<a href=\"~/App_Data/MinimalSpreadsheetLight.xlsx\" download=\"Spreadsheet file\">");
...yet, alas, to no avail.
UPDATE 2
I changed the pertinent line of HTML to this:
builder.Append("<a href=\"App_Data/MinimalSpreadsheetLight.xlsx\" download=\"Minimal Spreadsheet file\">");
...and it displays in the source like so (with some context):
<p>(Invoice Count excludes credits and re-delivery invoices)</p><p></p><p></p><a href="App_Data/MinimalSpreadsheetLight.xlsx" download="Minimal Spreadsheet file">
...but the link does not appear at all.
UPDATE 3
I was misled by this reference, which showed no text being added; I changed the code to this:
builder.Append("Spreadsheet file");
...(adding "Spreadsheet file" and closing out the anchor tag), and now the link appears; however, I still get the "Failed - No file" msg, and 2-clicking the "downloaded file" does nothing.
UPDATE 4
I tried two other permutations of what's seen in Update 3, namely with the forward whack reintroduced prior to "App_Data":
builder.Append("Spreadsheet file");
...and with both the squiggly prepended and the forward whack:
builder.Append("Spreadsheet file");
...but the results are the same in any of these permutations ("Failed - no file").
UPDATE 5
I also tried it without the "App_Data" at all, on the off change that is not needed:
builder.Append("Spreadsheet file");
...but the same "Failed - No file" is the result of that attempt, too.
UPDATE 6
Okay, so I tried this, too (single quotes):
builder.Append("<a href='/App_Data/MinimalSpreadsheetLight.xlsx' download='Minimal Spreadsheet file'>Spreadsheet file</a>");
...but no change. The file is there:
...so why is it not seen or accessible?
UPDATE 7
This:
string fullPath = HttpContext.Server.MapPath("~/App_Data/MinimalSpreadsheetLight.xlsx");
... (which I got from here) fails to compile with, "An object reference is required for the non-static field, method, or property 'System.Web.HttpContext.Server.get'
2-clicking the err msg highlights just "Server"
UPDATE 8
This (which I got from the same place as what I tried in Update 7):
string justDataDir = AppDomain.CurrentDomain.GetData("DataDirectory").ToString();
string url2 = string.Format("Spreadsheet file</button>", justDataDir);
builder.Append(url2);
...does nothing; clicking the link doesn't even give me a fake/failed download now...
justDataDir is:
C:\Projects\ProActWebReports\ProActWebReports\App_Data
url2 is:
Spreadsheet file</button>
UPDATE 9
I noticed on further fine-tooth-combing that url2 had a forward whack in it; I changed it so that all the whacks were back, but it made no difference to Update 8's results: clicking the link does nothing whatsoever.
If somebody solves this, it will definitely get bountified after the fact.
UPDATE 10
Maybe what I really need to do is, instead of the simple html, add some jQuery that will download the file. But the question is, can jQuery access the App_Data folder any better than raw/simple html can?
The app_data folder is used by iis and asp.net as a private area in which to put database files which can only be accessed by code running on the server.
If you try to access the folder directly via your browser you will get a permissions error.
In order to make the files available for download, move them the a folder under 'Content' (if you have an mvc site) and ensure that your web.config allows the .xlsx exention to be downloaded.
It may depend on what version of iis you are using.
Downloading Docx from IE - Setting MIME Types in IIS

Sublime Text 2 - AutoFileName

Is it possible to configure the AutoFileName plugin for Sublime Text 2 to recognize TypeScript reference path attributes and allow auto-completion for other .ts files in my project?
For example, if I had a file structure like:
scripts
models
MyModel.ts
services
MyService.ts
Then in MyService.ts, I would want the path attribute in the reference tag to allow auto-completion of ../models/MyModel.ts
/// <reference path="../models/MyModel.ts" />
I was hoping to be able to do this using the "auto_complete_triggers" setting in my user/preferences.sublime-settings file, but really have no idea how to do so.
This is a syntax (tmLanguage) issue
AutoFileName must recognize a string pattern inside the comment line for it to work.
I use ArcticTypescript and have just made a pull request to fix this tmLanguage issue. Edit: It is merged now.
If you use another package for syntax highlighting like better-typescript please open an issue to correct the syntax definition.
Open Preferences -> Package Settings -> AutoFileName -> Settings-Default and copy the entire contents to a new file (you can set the syntax to JSON if you prefer), then close the Default file (you never want to make changes to the default settings for any plugin, always use the User settings in case you mess something up and need to revert). Modify the "afn_valid_scopes" setting to include "ts", and you should be all set. Save the file as Packages/User/autofilename.sublime-settings where Packages is the folder opened when selecting Preferences -> Browse Packages....
If you used the following setting in your Sublime user preferences:
"auto_complete_triggers":
[
{
"characters": "/",
"selector": "string.quoted.double.html,string.quoted.single.html, source.css"
}
]
then add a comma , after source.css then add string source.ts and save.

Chrome developer tools workspace mappings

Can anyone tell me how the Chrome developer tools workspace mappings work.
I believe it is only available in Canary at the moment.
I thought it is supposed to allow me to make changes to the CSS rules in the elements view and have them automatically saved to the local files as demonstrated by Paul Irish at Google IO 2013. I can't get this functionality to work.
https://developers.google.com/events/io/sessions/325206725
It works only in canary at the moment.
EDIT: Now in Chrome (since ver 30+)
1) you need to open devtools settings panel. It has 'Workspace' section.
2) in this section you need to click on 'Add folder' item. It will show folder selection dialog.
3) After selecting a folder you will see an info bar about access rights for the folder.
4) As a result you will see two top level elements in the Source panel file selector pane. In my case it were localhost:9080 site and devtools local file system folder. At this moment you need to create a mapping between site files and your local files. You can do that via context menu on a file.
It doesn't matter what file to map, local or site file.
5) at that moment devtools will ask you about restart.
After restart devtools will show you the singe folder entry in the files pane and will apply all the changes you do to the local file each time when you press Ctrl + S or Cmd + S on mac.
Just a correction on what loislo has said.
"It works only in canary at the moment."
You can trigger all these experimental features in stable chrome releases by typing
Chrome://flags in the address bar.
Can anyone tell me how the Chrome developer tools workspace mappings work?
In current version of Chrome (I have version 80) the manual mapping option is gone. In the DevTools under Settings > Workspace it only says "Mappings are inferred automatically". From what I found the automatic mapping considers the following characteristics:
(1) Resource name and file name must be equal.
(2) Resource content and file content must be equal.
(3) The header field "Last-Modified" of the resource must be equal to the last modification date of the file on the file system.
Note that for (2) also the encoding must be the same. For example mixing "UTF-8" and "UTF-8 with BOM" will not work.
(3) Was not true in my case because I served the resource using a custom HttpServlet (Java), in which this header field was not set. Now I set this header field in my HttpServlet and the workspace mapping in Chrome is working. Simplified example:
#Override
protected void doProcess(HttpServletRequest httpRequest, HttpServletResponse httpResponse) throws IOException
{
try
{
// (1) file_name must be equal to the queried resource name of the website.
String path = "path/to/the/file_name.js";
File file = new File(path);
httpResponse.setContentType("application/javascript");
// (3) the Last-Modified header field of the resource must match the file's last modified date
httpResponse.setDateHeader("Last-Modified", file.lastModified());
// (2) the content of the resource must match the content of the file
// Note: CopyStream is a utility class not part of standard Java. But you get the idea ;)
CopyStream.copyAll(new FileInputStream(path), httpResponse.getOutputStream());
}
catch (Exception ex)
{
ex.printStackTrace();
}
}
For me I just needed to update Chrome (there was a light red "update" button that I'd been ignoring for some time).

Disable verbose output on build

When I use ST build system, "built-in output pane" prints various things like expected build output, but also cmd executed, active dir and path variable. Now cmd and dir are just fine, but printing path variable is totally unnecessary for me and it distracts actual output content, as it's just very long string of paths, shadowing all other output.
How can I instruct ST not to print path variable on build?
By adding "quiet": true to the Build System configuration file (JSON), you can prevent all "debug text" from appearing on build failure. This will include:
shell_cmd
cmd
dir
path
To exclude only path, you would need to modify the Packages/Default/exec.py file. Under the ExecCommand class, run method, look for self.debug_text += "[path: " and comment the line out.
To get to this file in ST3, you can use Package​Resource​Viewer, and type PRV: in the Command Palette to find Package​Resource​Viewer: Open Resource.
However, note that doing this, will create a file that will override the one that ships with ST3. So it is recommended to delete your override (Preferences -> Browse Packages from the menu, Default folder, exec.py) when a new build of ST comes out, as the official version may change to fix bugs etc. You can then re-apply your changes following the same steps as above, if it is still necessary. (Maybe an option will be added to exclude the path from the output, sometime in the future.)