Hosting standalone web app in IIS (directing host name to local runnig web application) - iis

There is a running stand alone web service running in windowserver its address http://localhost:1234, it starts running with double click of service.bat file,
In IIS, I have created a web site with hostname(myhostname) and set apps target folder as same path with service.bat,
and expected browsing from another computer like http://myhostname.com direct to this web app,
of course it doesnt work.. how can I achieve that?

IIS won't actively execute a bat file, unless executed with the help of asp.net applications. And for security reasons, by default iis will block access to the bat file, and you need to set the permissions of the application pool. Not only the bat file, but the exe file is the same. When executing the exe file with the asp.net application, you need to set the file in the folder and add the application pool as the executable.(You can refer to this answer)
If you want to redirect to localhost:1234 by myhostname.com,you can use url rewrite or redirect module ,then enable proxy in arr. This is detail steps.

Related

How to deploy command-line program (exe) on IIS server?

I have a classical command-line program (exe), taking some parameters and doing some stuff.
I would like to make it accessible via internet, i.e. via web browser.
I have a Windows server with IIS web server and a running web site.
Is there a way to deploy this exe command-line program directly? Can it be embedded into existing web site? If not, what is the way to proceed?
If yes, how do I pass parameters to the exe program?
As far as I know, .exe cannot be deployed on iis server, because the web applicaion on IIS has to be configured to be able to run executables. if you want to run .exe through IIS, you can try it this way:
Make your web site write a file that indicates the process needs to
be run.
Write a Windows ervice that runs on the web server that watches for the file that your web site creates.

My iis automatically points my solution directory though it's published

I have published my IIS application to C:/inetpub/wwwroot/appDirectory and it's have different configuration in web.config file.
and in development version solution directory i have another web.config file and When i build solution my IIS start pointing to solution directory.
that's too annoying, every time i need to remove application from iis and again make application on IIS itself.
Go to properties of your web service in Visual Studio.
Navigate to Web tab
Either Change the local IIS to express or you can give a different application name so it wont replace your deployed application.

How to restart a dnx website in production?

I updated a ASP.NET CORE/ASP.NET 5 RC1 controller cs file with a programming change.
The site has previously been deployed on production on IIS7.5 Windows 2012 Server which makes use of HTTPPlatformHandler installed in IIS.
This is a remote server I have to access via VPN.
The site is setup as an application in IIS and the folder points to the wwwroot directory of the deployed site.
I deploy it currently by deploying it first locally by right clicking on my project in Visual Studio 2015 and selecting publish to local folder. I then copy the contents of the local folder to the remote network IIS7.5 web server site folder.
If I copy for example the appsettings.json or a changed .cs file to the server, the change will not reflect.
If I copy the whole site to the production server I get folders and files in use messages. I have to kill the 'dnx' process in order to copy without getting these messages.
From my understanding if I kill the process dnx it will force a recompile. This is currently the only way I know of to restart the site after updating it but I imagine it is not the best way.
What is the standard practice to restart your website after you update your production sites that run ASP.NET5 RC1?
Also changing my app.settings json file aslo doesn't trigger a site reload like changing the web.config did in ASP.NET 4 so being able to restart a site is important.
If I have multiple sites on the same app pool and I only want to update one in production. How can I only restart the one site to reflect the latest changes?
Is it possibly to restart the website to reflect the change as updating it directly doesn't cause a recompile taking into consideration if I only have access to a shared folder and not the web server itself?
With IISPlatformHandler, DNX process is started by IIS (instructions are in wwwroot\web.config).
IIS knows nothing about your source files, all requests are forwarded to DNX.
DNX does NOT watch source files for changes, because there is no dnx-watch there.
IIS only watches for wwwroot\web.config file changes, so you need to change/edit/touch it to force IIS to restart website (and DNX process).
I use msdeploy to deploy, it has commands to stop and start app pools, using these commands has resolved my file in use errors. There are lots of ways to use msdeploy, below is how I happen to be using it.
msdeploy -verb:sync -source:recycleApp -dest:recycleApp="site/pool",recycleMode="StopAppPool",computername=COMPUTERNAME
msdeploy -source:contentPath='SOURCE PATH' -dest:contentPath='\\COMPUTERNAME\wwwroot\' -verb:sync -retryAttempts:2 -disablerule:BackupRule
msdeploy -verb:sync -source:recycleApp -dest:recycleApp="site/pool",recycleMode="StartAppPool",computername=COMPUTERNAME

Running nodejs/MEAN app on IIS virtual directory setup

I am running my MEAN app on windows. So far I was running the application on Non-Sucking Service Manager as a windows service. Now we need to enable windows authetication and we are planning to use IIS.
We are planning to use IISNode for this. So far I have read this post.
I installed the samples that comes with IISNode by running setupsamples.bat file.
running this file typically creates a virtual directory # C:\Program Files\iisnode\www
I want to understand If I need to run my application, Do I always need to copy all the content under C:\Program Files\iisnode\www folder? Or I can create a new virtual directory and make it work ?
I answered a similar question to this here
IISNode allows you operate your Node.js app just like you would any other application in IIS. Just make sure you have IISNode, Node.js, and the Url Re-write Module installed on the environment as well as a Web.config for your app and you should be good to go. Without the URL Re-write module then you would have to go to http://host:port/app.js/ instead of http://host:port and IISNode takes advantage of it to accomplish this.
In that thread I have a template Web.config that I use with all my IISNode services/web apps. It will support all aspects of hosting in IIS, including hosting your app in a Virtual Directory. Just make sure that the main file for your app matches the main file referenced in the config file within the URL Re-writing section.
If you are using VS then I recommend downloading the Node.js Tools for Visual Studio. It helps with creating the Web.config that you need for IISNode.

Creating Web-Site and Web Application in IIS

Till date, I was thinking that we always create/host web-site in IIS.
But I was going through powershell tutorial today which says it is different to create web-site and a web application.
This is the tutorial link (check different section on creating web site and application) -
http://learn.iis.net/page.aspx/433/powershell-snap-in-creating-web-sites-web-applications-virtual-directories-and-application-pools/
Can please guide what is the difference between the two.
Any example will be really helpful.
Thank you!
A web site in IIS is the top level under Sites. The default one that is normally automatically created for you when installing IIS is named "Default Web Site".
This is the "root" that runs on port 80.
Under that, you can create virtual directories, which is basically sub-levels under the root web site, or you can create separate web applications that lives as separate applications under the root level.
A web application must live under a web site.
It is possible to create other web sites that can either be set up to run on other ports (i.e. 81), or to be named with a different host name which enables multiple sites to run on same port number. If named with a different host name, this name must be registered in a DNS server somewere to point to the IP address for your server. A workaround is also to to add it as an entry in the hosts file on the client computer that should access it.
This is example on how it looks in IIS Manager:
I have a script I use when creating a website and AppPool in IIS 7+, .net4, Integrated pipeline and thought you might find it useful.
Use it as so:
CreateSite.ps1 [WebsiteName] [AppPoolName] [Port] [Path]
If you are reinstalling the site, you will need to Stop it first. That is done as so:
StopSite.ps1 [WebsiteName] [AppPoolName]
you can grab the scripts from my gist
Update I have added/extended the scripts and put them in their own Github repository
Here is my CreateWebsite PowerShell script: http://www.zerrouki.com/create-website/

Resources