Virtual Directory in IIS

Vote:
 

Hi.

Currently having a website hosted on-prem.

Client have a static website they wish to host on a subfolder to the Optimizely CMS application. I wish to separate the files and thus not make it a part of the CMS app (nor the code repo) and have added a Virtual Directory on the website i IIS pointing to a folder where the files resides. Browsing to the virtual directory shows however the 404-page set in the CMS application. The expected behavior is that IIS will present the static files instead.

Default Document is set correctly according to index.html that should be run/loaded. Navigating directly to "myvirtualfoldername/index.html" also shows the 404-page.

Any tips and/or pointers?

#319483
Mar 25, 2024 15:19
Vote:
 

You can't use the virtual directory approach with .NET Core based solutions: Virtual Directory Inside Of ASP.NET Core App In IIS (c-sharpcorner.com)

What benefit are you gaining from keeping the files separate if they are meant to be served as part of the same site? are you overcomplicating the matter?

If you really want to keep the code entirely separate, then you can look at these approaches:

  1. Create the static website as it's own website in IIS.  In the CMS solution create a a Middleware that detects traffic on a specific route and map it to return content from the static website.  You'd essentially map the route, make a web request and serve the results as your own response.
  2. Look at a proper Reserve Proxy solution
#319521
Mar 26, 2024 9:00
Vote:
 

Thanks Mark for your response.

I just got it to work locally by using app.UseDefaultFiles().

Yes, perhaps I am overcomplicating the matter.

The files in that folder is not within the web application scope and also developed and maintained by third party. I do not wish to give that party access to our code repo and build/deploy pipeline. :)

#319522
Mar 26, 2024 9:17
Vote:
 

I can see why you'd want to keep that separate in that case.  There is git based approach to this where your CMS repository has a reference to the Static Site Repository.  The third party agency would only have access to the Static Site Repository, but when you build the CMS repository, the latest from the static site repository is pulled in.  I'm not a fan of this, because I feel there are more elegant solutions.

Another approach I've seen is to have a "Campaign page" which uses a different layout template and mostly renderes raw HTML content and references JS and CSS files uploaded to the CMS.  The benefit here is that it allows you to secure pages and put them through a workflow process and to have the static individual pages exist at the correct hierarchy of the site.  You also gain the benefits of localisation and your static pages being incoprorated into the sitemap.  The third party doesn't need code access, just content access.

#319523
Mar 26, 2024 10:07
Vote:
 

That sounds like appropriate solutions (especially the second one), which I will look more into.

Thanks! 

#319534
Mar 26, 2024 12:58
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.