这些文件没有在IIS服务器中的MVC框架中加载

发布于 2025-01-20 17:11:12 字数 3999 浏览 2 评论 0原文

我第一次在IIS服务器上使用MVC框架。 我将.htaccess更改为web.config,并且正在发生非常奇怪的事情。 一些.cs和.js文件已加载,有些则没有。我完全不明白。 For example these files load correctly:

<script src="/assets/plugins/global/plugins.bundle.js"></script>
<script src="/assets/js/scripts.bundle.js"></script>

But for example this file is not loading:

<script src="/assets/js/custom/authentication/sign-in/general.js"></script>

my folders look like this:

-wwwroot
 web.config
   -public
      -assets
        -js
          -...

Maybe there is a problem in the configuration file.如果我在.js文件的地址之前写入文件夹 / public的名称,那么一切都很好。 也许你们中的一些人也有类似的问题,并且知道如何解决 Below is my configuration file code:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
  <system.webServer>
    <directoryBrowse enabled="false" />
    <rewrite>
      <rules>
        <rule name="rule 1p" stopProcessing="true">
          <match url="^$"/>   
            
          <action type="Rewrite" url="public/" />
        </rule>
        <rule name="rule 2p" stopProcessing="true">
          <match url="^(.*)$"/>
          <conditions>
            <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true"/>
            <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true"/>
          </conditions>
          <action type="Rewrite" url="public/index.php?{R:1}" appendQueryString="true"/>
        </rule>
        <rule name="phpmyadmin" stopProcessing="true">
            <match url="(.*)phpmyadmin(.*)" />
        </rule>
      </rules>
    </rewrite>
  </system.webServer>
</configuration>

EDIT

I changed physical path on the server to: C:\inetpub\wwwroot\public and also replace web.config to public folder

-wwwroot
   -public
     -web.config
      -assets
        -js
          -...

my web.congif file :

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <rewrite>
            <rules>
                <rule name="rule 1p" stopProcessing="true">
                  <match url="^(.+)/$"/>
                  <conditions>
                    <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true"/>
                    <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true"/>
                  </conditions>          
                  <action type="Rewrite" url="/{R:1}" />
                </rule>
                <rule name="Rule" stopProcessing="true">
                    <match url="^(.*)$" ignoreCase="false" />
                    <conditions logicalGrouping="MatchAll">
                        <add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" negate="true" />
                        <add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" negate="true" />
                    </conditions>
                    <action type="Rewrite" url="index.php?{R:1}" appendQueryString="true" />
                </rule>
            </rules>
        </rewrite>
    </system.webServer>
</configuration>

The only problem I have right now is that the main page is not showing up.所有子页面都可以正常工作,包括JS和CSS文件。 当我想显示我的主页EX时。 mypage.com,然后我遇到了一个错误:

http错误403.14-禁止将Web服务器配置为未列出 此目录的内容。详细的错误信息:模块DirectoryListingModule通知executereQuesthandler处理程序
静态文件错误代码0x00000000请求URL Localhost
物理路径C:\ inetpub \ wwwroot \ public 登录方法匿名登录用户匿名

when I want to display the home page after by mypage.com/home/index then the page is displayed but without js and css files

My first time using mvc framework on a iis server.
I changed the .htaccess to web.config and very strange things are happening.
some .css and .js files are loaded, some are not. I totally don't get it.
For example these files load correctly:

<script src="/assets/plugins/global/plugins.bundle.js"></script>
<script src="/assets/js/scripts.bundle.js"></script>

But for example this file is not loading:

<script src="/assets/js/custom/authentication/sign-in/general.js"></script>

my folders look like this:

-wwwroot
 web.config
   -public
      -assets
        -js
          -...

Maybe there is a problem in the configuration file. If I write name of folder / public / before the address to the .js files, then everything is good.
Maybe some of you had a similar problem and know how to solve it
Below is my configuration file code:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
  <system.webServer>
    <directoryBrowse enabled="false" />
    <rewrite>
      <rules>
        <rule name="rule 1p" stopProcessing="true">
          <match url="^
quot;/>   
            
          <action type="Rewrite" url="public/" />
        </rule>
        <rule name="rule 2p" stopProcessing="true">
          <match url="^(.*)
quot;/>
          <conditions>
            <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true"/>
            <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true"/>
          </conditions>
          <action type="Rewrite" url="public/index.php?{R:1}" appendQueryString="true"/>
        </rule>
        <rule name="phpmyadmin" stopProcessing="true">
            <match url="(.*)phpmyadmin(.*)" />
        </rule>
      </rules>
    </rewrite>
  </system.webServer>
</configuration>

EDIT

I changed physical path on the server to: C:\inetpub\wwwroot\public
and also replace web.config to public folder

-wwwroot
   -public
     -web.config
      -assets
        -js
          -...

my web.congif file :

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <rewrite>
            <rules>
                <rule name="rule 1p" stopProcessing="true">
                  <match url="^(.+)/
quot;/>
                  <conditions>
                    <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true"/>
                    <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true"/>
                  </conditions>          
                  <action type="Rewrite" url="/{R:1}" />
                </rule>
                <rule name="Rule" stopProcessing="true">
                    <match url="^(.*)
quot; ignoreCase="false" />
                    <conditions logicalGrouping="MatchAll">
                        <add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" negate="true" />
                        <add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" negate="true" />
                    </conditions>
                    <action type="Rewrite" url="index.php?{R:1}" appendQueryString="true" />
                </rule>
            </rules>
        </rewrite>
    </system.webServer>
</configuration>

The only problem I have right now is that the main page is not showing up. All subpages work properly, including js and css files.
when i want to display my home page ex. mypage.com then i get such an error:

HTTP Error 403.14 - Forbidden The Web server is configured to not list
the contents of this directory. Detailed Error Information: Module DirectoryListingModule Notification ExecuteRequestHandler Handler
StaticFile Error Code 0x00000000 Requested URL localhost
Physical Path C:\inetpub\wwwroot\public
Logon Method Anonymous Logon User Anonymous

when I want to display the home page after by mypage.com/home/index then the page is displayed but without js and css files

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

糖粟与秋泊 2025-01-27 17:11:12

此问题可能会发生,因为网站没有启用目录浏览功能。要解决此问题,您可以尝试使用以下方法:

  1. start IIS Manager。为此,选择“启动”,选择“运行”,“键入inetmgr.exe”,然后选择“确定”。
  2. 在IIS Manager中,扩展服务器名称,扩展网站,然后选择要更改的网站。
  3. 在功能视图中,双击目录浏览。
  4. 在动作窗格中,选择启用。

This problem may occurs because the website doesn't have the Directory Browsing feature enabled. To resolve this problem,you can try use the following methods:

  1. Start IIS Manager. To do it, select Start, select Run, type inetmgr.exe, and then select OK.
  2. In IIS Manager, expand server name, expand Web sites, and then select the website that you want to change.
  3. In the Features view, double-click Directory Browsing.
  4. In the Actions pane, select Enable.
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文