Preview /run HTML website with Server Side Includes using Visual Studio Code - apache

I am used to server-side programming (.NET). Developing a very simple HTML for a Linux /Apache server for the first time I am (heavily) using SSI to include bits of code I'd have otherwise to repeat on each and every page, i.e. header, footer etc...
My website works just fine when deployed to production but I cannot get it work during Visual Studio Code development. What kind of web server does it use? Is the any way (add-on maybe?) to have it process correctly my .shtml files with includes before rendering HTML output?

Related

VS Code Apache Live Server

Is it possible to make apache server on my pc /same as I working with vs code/ setup as my vs code live server?
Like the live server extension, when I save /ctrl+s/ the browser page refresh it.
The vs code live server extension is useless.
I created a website /html, css, js/ which working perfect in Live Server.
When I uploaded to the server the website is useless.
I have to start again from the beginning. More than a week work landed in the trash.
Apache, because most of the servers are apache, and I do not want to throw a week in the trsh again.
I am study html, css, js as my hobby. I am a beginner. I am not working as programer, and not this is my target. Just study for fun.

How to locally run .Net Core 2.0 app in VS Code the same way Visual Studio does with SSL

So, we have a web app we've migrated to .net core, and while it runs fine in Visual Studio 2017, because Visual Studio uses its "launchSettings.json" file to configure how IIS Express will work/launch - I, for the life of me, cannot figure out how to get VS Code to run the project. The problem is, we use HTTPS only and have always just let IIS Express used the self-signed locahost cert to allow this, so when debugging the site locally, we'd always use https://localhost:44300. As stated, this worked fine when entering this url in the launchSerttings.json file for Visual Studio, but VS Code does not use this, and the only answers I can find on this always refer to having to use the Kestrel Server's .Listen() method and used a self-signed cert and password to allow the use of an HTTPS port. 1) this seems just silly that I'd have to add this "test" code to run it locally, because I don't need it when we deploy to Azure, as Azure manages the certs and url for us. 2) Visual Studio 2017 does not need any specification on Kestrel to make this all work. So, I have hard time believing there isn't some extension, or process to achieve the same thing in Visual Studio Code that Visual Studio is doing under the hood to allow IIS Express to communicate with the .Net Core Kestrel Server.
Combing through the all the documentation suggests that the ASPNetCoreModule is what handles this communication for IIS and Kestrel, so, I would hope/guess there has to be some way to configure the web.config file's tag to include something that would make this work.
I've previously used and tried other IIS execution extensions in VS Code, but those focus on elements in the project's web.config to boot IIS which are no longer present in the web.config due to it being a .Net Core app. I had been successfully running the web app with the IIS Express Executor extension before migrating to .Net Core when the web app was a .NET Framework 4.5.2 app
So, the end goal is that I need to be able to go to https://localhost:44300 in the browser, and have our site work, but I don't want to have to add any sort of test-cert into the Kestrel config in the Program.cs or Startup.cs files. If there's no way to do this, then that will be really disappointing considering Visual Studio makes this seem like it should be very simple.
Thanks for the help.
Was able to get this to work using the following steps.
1) Install IIS Express executer in VS Code or any other similiar extension that wraps around dotnet commands
2) Download Process Explorer from https://learn.microsoft.com/en-us/sysinternals/downloads/process-explorer
3) Launch Visual Studio IIS Express as you would normally
4) Open Process Explorer (may need to launch as Admin) and locate iisexpress.exe -> VSIISExeLauncher.exe
5) Right click VSIISExeLauncher.exe and click properties then locate the "Environment" tab. Inside the environment tab you will see 2 variables: LAUNCHER_PATH and LAUNCHER_ARGS. Copy both of these variables and values.
6) Next locate the configuration file for the extension you installed in VS code (mine is launch.json inside the .vscode folder in your project root directory). It will likely have an "environment" or "env" section for adding environment variables to the launch arguments. Add the two arguments copied from step 5. These vary from person to person so the value of the arguments will be unique to your machine.
7) Launch IIS-Express from vs code. My particular command for this is "IIS-EE: Start IIS Express Server" but will vary based on the extension you installed. You can hit F1 to launch commands.
Visual Studio itself uses too many tricks under the hood to make you believe it is simple. However, it is not.
I documented all necessary details in a blog post,
https://blog.lextudio.com/how-visual-studio-launches-iis-express-to-debug-asp-net-core-apps-d7fd3677e3c3
And if you follow the steps manually, you should be able to launch IIS Express the same way VS does, and then use that in Visual Studio Code. I know there is some VSCode extensions trying to integrate with IIS and IIS Express, but I do hope those authors spend more time learning such integration and improve their extensions to fully support the scenarios.

Easy way to have a VB.Net WindowsForms application work as a web app?

I have made a small text based game using VB.NET in a Windows Forms application but it seems that people are a bit hesitent when it comes to downloading exe files. What would an easy way to have it work as a web application without having to rewrite the entire code?
There isn't an "easy" way to turn it into a web application. You can take all of your logic and put it into libraries (Class Library), but you'll need to write new front-end code for both the desktop and web.
If you are wanting the web to accept user input and such without constant reloading, you'll also need to make a web service to talk to using jQuery or the like.
For what it's worth, if anyone is hesitant to download an EXE, then they don't need it. I used to publish installations for VB6 applications on my website years ago, and I had downloads and referrals from all over the place, including educational institutions.
Also, if you are direct linking to an EXE, consider packaging it up in a ZIP along with a readme file.

How to make use of common files across projects using an IIS7 virtual directory

The scenario:
I'm very new to ASP.Net MVC programming and running into a wall constantly trying to make use of common files (.js, .css) across multiple projects.
The idea is to have these generic files in 1 location which provides for easy future updates and avoids the "copy and paste" dilemma across all the projects. I've set this folder up in IIS7 as a virtual directory in the default website with an alias "CommonFiles".
The problem:
With MVC-4 I'm trying to add the js files to a script bundle but upon running the application it's not picking the files up at all. (checked in the page source and also added a js function as a test)
Code snippet in BundleConfig.cs:
bundles.Add(new ScriptBundle("~/bundles/test").Include("~/CommonFiles/test.js"));
Rendering in _Layout.cshtml:
#Scripts.Render("~/bundles/test")
I've read quite a few posts (
Script Bundling in WebForms with Virtual Directories (asp webforms though), How to add reference to System.Web.Optimization for MVC-3-converted-to-4 app, ScriptBundle not rendering scripts that are in a VirtualDirectory) but i'm afraid my lack of knowledge on MVC is limiting my path forward and really hoping to get some insight into how MVC handles IIS virtual directories and if it's even an easy possibility given the last post i've read above.
Can this be done in MVC-4 and if not what is a second best alternative in reusing common code across projects?
After reading a post by kev (Using ServerManager to create Application within Application) it put me on the right path and the issue I had is actually embarrassing.
For the sake of other devs landing on this post with a similar issue in visual studio, this is what fixed my issue:
Problem:
I make use of a separate project which contains files that are used across multiple other projects. I created a virtual folder in IIS7 referencing these files. This means if a change is needed to the common files, it's updated once and all the other projects will automatically "see" the change.
My other individual projects make use of script bundling to include files relevant only to the said project, but also to reference the common files in the virtual folder as defined in IIS.
My MVC-4 web application wasn't picking up the common files given the syntax above, in neither debug or release..
Solution:
When developing in VS2012, under the project's properties, there's a setting under the web tab where you can specify whether you want to use local IIS web server or IIS Express to test your application. IIS Express adds a random port to the site in order to test, and to allow multiple instances of sites to run (on different ports). This seems to throw the virtual directory include off in the bundling.
Choosing to use the local IIS server is closer to what the "live" environment would be in my opinion. Just un-tick the "Use IIS Express" setting.
As a side note and for more info on what the difference between the usage of IIS and IIS express is and whether it's suitable for your environment (as it was for mine) see this link:
http://msdn.microsoft.com/en-us/library/58wxa9w5.aspx
Hope this helps someone in future and saves them the amount of time I wasted on this!

How to code vb.net for website? I want the UI embedded within the web page of my browser

I have made an exe program using vb.net but I want to make a webpage on which that exe is embedded.
Like the way this site has done.
You already have the source code for your VB.NET application, the path of least resistance is to factor out the desired functionality into a library DLL. Your web server presumably runs Windows and so will probably have ASP.NET capability. Just reference the DLL in your ASP.NET project and call into that instead.
My advice is don't make a rod for your own back by creating your own CGI binaries:
With a CGI application you'll have to generate all of the response headers and markup by yourself, you'll also have to parse any inbound headers, cookies etc yourself. It's a lot of work to replicate functionality already present in ASP.NET
Enabling CGI executables on your web server increases the risk of a security compromise, either through a mistake in your VB.NET executable, or because via some other vector an attacker has been able to upload a malicious executable and run that.