簡體   English   中英

找不到IIS Express靜態文件

[英]IIS Express static files not found

讓我先說一下,我有一個Linux背景,在Windows上開發對我來說是相當新的。

我正在研究我在Visual Studio中打開的ASP.NET項目。 該項目最初設置為通過IIS運行。 VS有用地問我是否想嘗試IIS Express,我說是的。 該應用程序最初有一些打嗝,但這是因為代碼是古老而巨大的。 解決這些問題后,應用程序加載正常,除了任何靜態文件。 對於文件系統中實際存在的資源,我找到了404 Not Found。

您在照片中看到的物理路徑存在於Web.config文件旁邊的文件夾中。 我可以從exec目錄加載aspx文件,該目錄是圖形目錄的兄弟。 圖形目錄是我想在這張圖片中加載的favicon.ico文件的位置。

我今天已經閱讀了很多關於IIS和IIS express的文檔,但沒有人提到必須對靜態文件做任何特殊操作。 也許我只是厚厚的。 如果需要我的Web.config讓我知道,我可以在這里附上它。

IIS Express錯誤頁面

編輯:

1)在此方面取得了一些進展。 我在完整的IIS下也得到完全相同的錯誤。 我的靜態內容沒有顯示出來。

2)這是請求的web.config

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
  <configSections>
    <section name="loggingConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.LoggingSettings, Microsoft.Practices.EnterpriseLibrary.Logging, Version=6.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="true" />
  </configSections>
  <!--
    For a description of web.config changes see http://go.microsoft.com/fwlink/?LinkId=235367.

    The following attributes can be set on the <httpRuntime> tag.
      <system.Web>
        <httpRuntime targetFramework="4.5" />
      </system.Web>
  -->
  <loggingConfiguration name="loggingConfiguration" tracingEnabled="true" defaultCategory="General">
    <listeners>
      <add name="Event Log Listener" type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.FormattedEventLogTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging, Version=6.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.FormattedEventLogTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging, Version=6.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" source="Enterprise Library Logging" formatter="Text Formatter" log="" machineName="." traceOutputOptions="DateTime, Timestamp, ProcessId" />
      <add name="W3C Rolling Flat File Trace Listener" type="App.W3CLogTraceListener, App, Version=1.0.0.0, Culture=neutral" listenerDataType="App.W3CLogTraceListenerData, App, Version=0.0.0.0, Culture=neutral" fileName="appA65.log" fileHeader="date time session-id client-ip page url form-data cookie" footer="" formatter="Text Formatter" header="" rollInterval="Midnight" timeStampPattern="yyyy-MM-dd" />
    </listeners>
    <formatters>
      <add type="Microsoft.Practices.EnterpriseLibrary.Logging.Formatters.TextFormatter, Microsoft.Practices.EnterpriseLibrary.Logging, Version=6.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" template="{message}" name="Text Formatter" />
    </formatters>
    <logFilters>
      <add type="Microsoft.Practices.EnterpriseLibrary.Logging.Filters.LogEnabledFilter, Microsoft.Practices.EnterpriseLibrary.Logging, Version=6.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" enabled="false" name="Logging Enabled Filter" />
    </logFilters>
    <categorySources>
      <add switchValue="All" name="General">
        <listeners>
          <add name="W3C Rolling Flat File Trace Listener" />
        </listeners>
      </add>
    </categorySources>
    <specialSources>
      <allEvents switchValue="All" name="All Events" />
      <notProcessed switchValue="All" name="Unprocessed Category" />
      <errors switchValue="All" name="Logging Errors &amp; Warnings">
        <listeners>
          <add name="Event Log Listener" />
        </listeners>
      </errors>
    </specialSources>
  </loggingConfiguration>
  <appSettings>
    <!-- To enable or disable IETP user session management, true to enable, false to disable -->
    <add key="IetpSessionEnabled" value="false" />
    <!-- To specifies where the folder for session files -->
    <add key="IetpUserSessionServerPath" value="d:\apps\ietpusersessions" />
    <!-- To determines the duration of s user session in terms of minutes -->
    <add key="IetpUserSessionLengthInMinutes" value="600" />
    <!-- to enable/disable sending out email on exceptions, true to enable, false to disable -->
    <add key="EmailAlertEnabled" value="true" />
    <!-- the exception email alert list, seperated by comma -->
    <add key="EmailAlertToAddress" value="alice@example.com" />
    <!-- email sender address -->
    <add key="EmailAlertFromAddress" value="bob@example.com" />
    <!-- to enable or disable Pdf print, wehn set "true", all user local print requests will be -->
    <!-- processed on the server and the final PDF will be rended in browser -->
    <add key="PdfPrintEnabled" value="true" />
    <add key="PdfPrintServiceUrl" value="https://example.com/PdfPrintService/PdfPrintService/PDFPrint.aspx" />
    <add key="FooterDisclaimer" value="Footer here" />
  </appSettings>
  <system.web>
    <httpRuntime targetFramework="4.0" requestValidationMode="2.0" />
    <!-- <httpRuntime executionTimeout="300" /> -->
    <compilation debug="true" defaultLanguage="c#" targetFramework="4.5.1" />
    <customErrors defaultRedirect="~/exec/generalError.aspx" mode="Off" />
    <sessionState mode="StateServer" stateConnectionString="tcpip=localhost:42424" cookieless="false" stateNetworkTimeout="11" timeout="600" />
    <pages controlRenderingCompatibilityVersion="4.0" />
  </system.web>
  <system.webServer>
    <modules runAllManagedModulesForAllRequests="true">
      <remove name="URLWriteHttpModule" />
      <add name="URLWriteHttpModule" type="App.URLWriteHttpModule" />
    </modules>
    <defaultDocument>
      <files>
        <clear />
        <add value="default.aspx" />
        <add value="Default.asp" />
        <add value="Default.htm" />
        <add value="index.htm" />
        <add value="index.html" />
      </files>
    </defaultDocument>
    <tracing>
      <traceFailedRequests>
        <add path="*">
          <traceAreas>
            <add provider="ASP" verbosity="Verbose" />
            <add provider="ASPNET" areas="Infrastructure,Module,Page,AppServices" verbosity="Verbose" />
            <add provider="ISAPI Extension" verbosity="Verbose" />
            <add provider="WWW Server" areas="Authentication,Security,Filter,StaticFile,CGI,Compression,Cache,RequestNotifications,Module,FastCGI" verbosity="Verbose" />
          </traceAreas>
          <failureDefinitions timeTaken="00:00:00" statusCodes="500-599" verbosity="Error" />
        </add>
      </traceFailedRequests>
    </tracing>
        <handlers accessPolicy="Read, Execute, Script" />
  </system.webServer>
</configuration>

最終編輯 - 我從來沒有真正弄清楚出了什么問題。 重新安裝操作系統修復了這個問題,我再也無法復制它了。

你能嘗試添加嗎?

<system.webServer>
    <modules runAllManagedModulesForAllRequests="true" />
</system.webServer>

IIS Pre條件

您是否在IIS中啟用了靜態內容?

在此輸入圖像描述

  1. 檢查你的gloabl.asax存在這種線

    routes.IgnoreRoute( “{}資源個.axd / {*} PATHINFO”); 或routes.IgnoreRoute(“{ favicon}”,new {favicon = @“( 。/)?favicon.ico /。*)?”});

或類似的東西

  1. 注釋url重寫部分並檢查其工作情況?

我相信你仔細檢查文件是否存在正確的路徑:)

檢查您的靜態內容是否通過MSBuild發布。 如果沒有,請將這些行添加到.csproj文件中:

<ItemGroup>
    <Content Include="graphics\**\*.*" />
</ItemGroup>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM