【问题标题】:The images do not show on page after publishing the web-application on IIS在 IIS 上发布 Web 应用程序后,图像未显示在页面上
【发布时间】:2016-11-28 01:41:52
【问题描述】:

在 IIS 上发布 Web 应用程序后,图像不会显示在页面上。

当我从 Visual Studio 2015 运行 Web 应用程序时,图片显示正确。图片路径如下

/media/1713/mypicture.png

但在 IIS 上发布 Web 应用程序并运行它后,图片不显示。 但是当我在上述路径的第一个手动添加域时,图像正确显示。和

一样

/domain-name/media/1713/mypicture.png.

我使用过 Umbraco 7.4.3、ASP.NET MVC、VS2015 和 Windows 10。

编辑:我将它升级到 UMBRACO 7.5.4 但仍然存在问题。 :(

我该如何解决这个问题?请帮帮我。

umbracosettings.config:

<?xml version="1.0" encoding="utf-8" ?>
<settings>

  <content>

    <errors>
      <error404>1</error404>
    </errors>

    <notifications>
      <!-- the email that should be used as from mail when umbraco sends a notification -->
      <email>your@email.here</email>
    </notifications>

    <!-- Show property descriptions in editing view "icon|text|none" -->
    <PropertyContextHelpOption>text</PropertyContextHelpOption>

    <!-- The html injected into a (x)html page if Umbraco is running in preview mode -->
    <PreviewBadge>
      <![CDATA[<a id="umbracoPreviewBadge" style="position: absolute; top: 0; right: 0; border: 0; width: 149px; height: 149px; background: url('{1}/preview/previewModeBadge.png') no-repeat;z-index: 9999999;" href="#" OnClick="javascript:window.top.location.href = '{0}/endPreview.aspx?redir={2}'"><span style="display:none;">In Preview Mode - click to end</span></a>]]></PreviewBadge>

    <!-- Cache cycle of Media and Member data fetched from the umbraco.library methods -->
    <!-- In seconds. 0 will disable cache -->
    <UmbracoLibraryCacheDuration>1800</UmbracoLibraryCacheDuration>

    <!-- How Umbraco should handle errors during macro execution. Can be one of the following values:
         - inline - show an inline error within the macro but allow the page to continue rendering. Historial Umbraco behaviour.
         - silent - Silently suppress the error and do not render the offending macro.
         - throw  - Throw an exception which can be caught by the global error handler defined in Application_OnError. If no such
                    error handler is defined then you'll see the Yellow Screen Of Death (YSOD) error page.
         Note the error can also be handled by the umbraco.macro.Error event, where you can log/alarm with your own code and change the behaviour per event. -->
    <MacroErrors>throw</MacroErrors>

    <!-- These file types will not be allowed to be uploaded via the upload control for media and content -->
    <disallowedUploadFiles>ashx,aspx,ascx,config,cshtml,vbhtml,asmx,air,axd,swf,xml,html,htm,svg,php,htaccess</disallowedUploadFiles>

    <!-- Defines the default document type property used when adding properties in the back-office (if missing or empty, defaults to Textstring -->
    <defaultDocumentTypeProperty>Textstring</defaultDocumentTypeProperty>
  </content>

  <security>
    <!-- set to true to auto update login interval (and there by disabling the lock screen -->
    <keepUserLoggedIn>false</keepUserLoggedIn>
    <!-- change in 4.8: Disabled users are now showed dimmed and last in the tree. If you prefer not to display them set this to true -->
    <hideDisabledUsersInBackoffice>false</hideDisabledUsersInBackoffice>
  </security>

  <requestHandler>
    <!-- this will ensure that urls are unique when running with multiple root nodes -->
    <useDomainPrefixes>false</useDomainPrefixes>
    <!-- this will add a trailing slash (/) to urls when in directory url mode -->
    <addTrailingSlash>true</addTrailingSlash>   
  </requestHandler>

  <templates>
    <!-- To switch the default rendering engine to MVC, change this value from WebForms to Mvc -->
    <defaultRenderingEngine>Mvc</defaultRenderingEngine>
  </templates>

  <scheduledTasks>
    <!-- add tasks that should be called with an interval (seconds) -->
    <!--    <task log="true" alias="test60" interval="60" url="http://localhost/umbraco/test.aspx"/>-->
  </scheduledTasks>

  <!-- distributed calls must be enabled when using Umbraco in a load balanced environment -->
  <distributedCall enable="false">
    <!-- the id of the user who's making the calls -->
    <!-- needed for security, umbraco will automatically look up correct login and passwords -->
    <user>0</user>

    <!--
    When distributed call is enabled, you need to add all of the servers part taking in load balancing
    to the server list below. 
    -->

    <servers>

    </servers>
  </distributedCall>
  <web.routing
    trySkipIisCustomErrors="false"
    internalRedirectPreservesTemplate="false" disableAlternativeTemplates="false" disableFindContentByIdPath="false"
    umbracoApplicationUrl="">
  </web.routing>

</settings>

我在我的 cshtml 文件中使用了 img 标签,如下所示:

<img style="display: block;" src="@Model.Model.MainPicture" alt="@Model.Model.FirstTitle">

【问题讨论】:

  • 您是否正在运行多站点 Umbraco 实例? / 您是否在网站上正确设置了主机名?
  • 您可能需要使用 Umbraco API“获取”媒体项的 URL:our.umbraco.org/documentation/Reference/Management/Services/…
  • 谈到“域名”,你到底想什么?在我看来,它看起来更像是 IIS 配置问题。 web.config () 中有一个设置可以帮助您隐藏路径中的顶级节点。先试试这个。并分享更多关于域名的信息。您在 IIS 网站上使用什么类型的域?
  • 我在路径 C:\inetpub\wwwroot\art-and-cake 中创建了一个名为“art-and-cake”的文件夹。 DOMAIN-NAME 是“art-and-cake” 我检查了 umbracoHideTopLevelNodeFromPath 的值。这是“真的”。
  • 所以你需要在 IIS 上建立一个网站并指向这个目录。现在您正尝试从根应用程序浏览它,它指向正确路径上的图像(带有目录名称)。检查:our.umbraco.org/documentation/getting-started/setup/install/….

标签: iis umbraco umbraco7 webdeploy


【解决方案1】:

有时,如果您在项目中添加的图像不是以通常方式包含的,它不会更新您提交给 IIS 的构建/包中的图像。在解决方案资源管理器中制作您的图像,右键单击解决方案资源管理器中的图像并选择属性,然后选择“始终复制”并构建项目。然后发布到 IIS。

【讨论】:

  • 图片很多。请获得一个通用的解决方案。我有一个文件夹“媒体”,管理员可以上传他/她的图片。
  • 问题在于通过 CMS 添加的图像,因此它们不能包含在代码解决方案中。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-11-30
  • 2012-09-29
  • 2014-04-14
  • 2023-04-10
  • 1970-01-01
相关资源
最近更新 更多