Can anyone actually get server side includes to work inside VS2019 (IIS Express)

SeanD-9054 101 Reputation points
2020-12-03T18:30:31.057+00:00

I have see at least a dozen web posts regarding SSI on IIS Express and/or in Visual Studio. None of them have had any effect for me.

I just want to have a .html file use <!--#INCLUDE FILE="nav.shtml"--> or <!--#INCLUDE FILE="nav.inc"--> and have the file included!

It of course works fine on our server with SSI enabled. I have edited different .config files. I have configured it for .inc and for .shtml and in every case if I view source I just see the include tag.

There must be a way to run my code without deploying to a server.

Thanks,
Sean

ASP.NET Core
ASP.NET Core
A set of technologies in the .NET Framework for building web applications and XML web services.
4,118 questions
Visual Studio
Visual Studio
A family of Microsoft suites of integrated development tools for building applications for Windows, the web and mobile devices.
4,557 questions
0 comments No comments
{count} votes

Accepted answer
  1. SeanD-9054 101 Reputation points
    2020-12-04T14:50:56.437+00:00

    I can now answer my question. I hope this helps others. After at least a year of attempts to get IIS Express (from Visual Studio debugger) to perform Server Side includes it came to me in my sleep last night! The key was a comment in another post that said SSI only works if you rename your html files to .ASP files.

    The existing line in applicationhost.config (in .vs/<project name>/config) is:
    <add name="SSINC-shtml" path=".shtml" verb="GET,HEAD,POST" modules="ServerSideIncludeModule" resourceType="File" />
    and I added
    <add name="SSINC-inc" path="
    .inc" verb="GET,HEAD,POST" modules="ServerSideIncludeModule" resourceType="File" />
    But I could never understand why .shtml or .inc files were not included.

    It is not the file being included that needs the handler mapper, it is the file doing the including, i.e. the one with the <!--#INCLUDE line in it. In my case, and many others, this is the .html file. Adding a handler line for the .HTML files fixed the problem.
    <add name="SSINC-html" path="*.html" verb="GET,HEAD,POST" modules="ServerSideIncludeModule" resourceType="File" />

    HTH,
    Sean

    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Sam Wu-MSFT 7,036 Reputation points Microsoft Vendor
    2020-12-04T05:56:59.443+00:00

    Hi @SeanD-9054 ,

    Can anyone actually get server side includes to work inside VS2019 (IIS Express)

    There must be a way to run my code without deploying to a server.

    According to your description, I couldn’t understand your requirement clearly.

    But from your title, I seem to understand that you want to achieve the effect of deploying to the server in vs. If so, then you can try to use local IIS server.

    45112-8.png

    More information about how to ues local IIS server you can refer to this link: how-to-enable-debugging-for-aspnet-applications


    If the answer is helpful, please click "Accept Answer" and upvote it.

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.