locked
Problems with VS2019 ASP.NET project and href links RRS feed

  • Question

  • User-1290125685 posted

    Hi,

    I have a problem with the url used in the href attribute for my style sheets. The website should run under a directory I will call /MyWebSite. I have added the virtual directory to my applicationhost.config so that it look like this:

            <sites>
                <site name="WebSite1" id="1" serverAutoStart="true">
                    <application path="/">
                        <virtualDirectory path="/" physicalPath="%IIS_SITES_HOME%\WebSite1" />
                    </application>
                    <bindings>
                        <binding protocol="http" bindingInformation=":8080:localhost" />
                    </bindings>
                </site>
                <site name="Web Site" id="2">
                    <application path="/" applicationPool="Clr4IntegratedAppPool">
                        <virtualDirectory path="/" physicalPath="D:\Visual Studio 2019\My Web Site\My Web Site" />
                    </application>
                    <application path="/MyWebSite" applicationPool="Clr4IntegratedAppPool">
                        <virtualDirectory path="/" physicalPath="D:\Visual Studio 2019\My Web Site\My Web Site" />
                    </application>
                    <bindings>
                        <binding protocol="http" bindingInformation="*:50380:localhost" />
                    </bindings>
                </site>
                <siteDefaults>
                    <!-- To enable logging, please change the below attribute "enabled" to "true" -->
                    <logFile logFormat="W3C" directory="%AppData%\Microsoft\IISExpressLogs" enabled="false" />
                    <traceFailedRequestsLogging directory="%AppData%\Microsoft" enabled="false" maxLogFileSizeKB="1024" />
                </siteDefaults>
                <applicationDefaults applicationPool="Clr4IntegratedAppPool" />
                <virtualDirectoryDefaults allowSubDirConfig="true" />
            </sites>

    Now I can open my top page using http://localhost:50380/MyWebSite/StartPage.aspx and all the page links work.

    Now, in start page I have the following tag in StartPage.aspx:

    <link rel="stylesheet" type="text/css" href="/MyWebSite/Styles/Styles.css" />

    However, the style sheet is not being loaded. Can anyone tell me how I can get this to work?

    Thank You

    Friday, March 19, 2021 1:05 AM

All replies

  • User-939850651 posted

    Hi RabbitWolf,

    I have a problem with the url used in the href attribute for my style sheets. The website should run under a directory I will call /MyWebSite. I have added the virtual directory to my applicationhost.config so that it look like this:

    I don't know the structure of your project in IIS, so I'm afraid I can't determine the cause of your problem.

    This is one of the possibilities: If static files are added as virtual directories, they must be added to the main application.

    For more details, you could refer to this similar case: Flask static folder not served on IIS

    If I understood something, could you provide the structure of your project in IIS?

    Best regards,

    Xudong Peng

    Friday, March 19, 2021 9:56 AM