Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Execute javascript on IIS server

I have the following situation. A customer uses JavaScript with jQuery to create a complex website. We would like to use JavaScript and jQuery on the server (IIS) for the following reasons:

  1. Skills transfer - we would like to use JavaScript and jQuery on the server and not have to use eg VB Script. / classic asp. .Net framework/Java etc is ruled out because of this.

  2. Improved options for search/accessibility. We would like to be able to use jQuery as a templating system, but this isn't viable for search engines and users with js turned off - unless we can selectively run this code on the server.

There is significant investment in IIS and Windows Server, so changing that is not an option.

I know you can run jScript on IIS using windows Script host, but am unsure of the scalability and the process surrounding this. I am also unsure whether this would have access to the DOM.

Here is a diagram that hopefully explains the situation. I was wondering if anyone has done anything similar?

EDIT: I am not looking for critic on web architecture, I am simply wanting to know if there are any options for manipulating the DOM of a page before it is sent to the client, using javascript. Jaxer is one such product (no IIS) Thanks.

like image 471
James Westgate Avatar asked Apr 27 '10 08:04

James Westgate


People also ask

Can IIS run JavaScript?

Introduction. Windows supports the JavaScript in the shell and web server without the need to install node. js or any other server-side JavaScript engine. This article contains the most first steps for creating JavaScript applications for MS Windows Shell and MS Windows web server (IIS).

Can JavaScript be executed on server?

Running JavaScript on the server allows your developers to work on both frontend and backend. They will know the entire project much better and altogether avoid the communication overhead between separate teams. They can implement every feature from start to finish by a single developer.

How do I enable JavaScript in IIS 7?

On the "Security" tab, make sure the Internet zone is selected, and then click on the "Custom level..." button. In the Security Settings – Internet Zone dialog box, click Enable for Active Scripting in the Scripting section.


2 Answers

Have a look at bringing the browser to the server, Rhino, and Use Microsoft's IIS as a Java servlet engine.

The first link is from John Resig's (jQuery's creator) blog.

Update August 2 2011

Node.js is coming to Windows.

like image 113
David Murdoch Avatar answered Sep 28 '22 10:09

David Murdoch


The idea to reuse client JS on the server may sound tempting, but I am not sure that jQuery itself would be ready to run in server environment.

You will need to define global context for jQuery somehow by initializing window, document, self, location, etc.. I am not sure it is doable.

Besides, as Cheeso has mentioned, Active Server Pages is a very outdated technology, it was replaced with ASP.Net by Microsoft in the beginning of the century. I used to maintain a legacy system using ASP 3.0 for more than a year and that was pain. The most wonderful pastime was debugging: you will hardly find anything for the purpose today and will have to decript beautiful errors like in IIS log:

error '800a9c68'
Application-defined or object-defined error

Nevertheless, I can confirm that I managed to reuse client and server JScript. But this was code written by me who knew that it was going to be used on the server.

P.S. I would not recommend move that way. There are plenty templating frameworks which are familiar to those who write HTML and JavaScript.

like image 35
newtover Avatar answered Sep 28 '22 08:09

newtover