我怎样才能让Sitecore的显示图像(或其他资源) [英] How can I make sitecore showing an image (or other resources)

查看:236
本文介绍了我怎样才能让Sitecore的显示图像(或其他资源)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我安装干净Sitecore的6.6并启用了MVC的支持,使用该<一href="http://www.sitecore.net/Community/Technical-Blogs/John-West-Sitecore-Blog/Posts/2012/06/Sitecore-MVC-Playground-Part-1-Enable-MVC.aspx"相对=nofollow>指南。所以,我的环境是Sitecore的6.6,ASP .NET MVC 3剃须刀,Microsoft SQL Server的防爆preSS 2012,IIS 7.5和我使用Microsoft Visual Studio 2012例preSS的网络。我有以下code:

I installed clean Sitecore 6.6 and enabled MVC support using this guide. So my environment is Sitecore 6.6, ASP .NET MVC 3 and Razor, Microsoft SQL Server Express 2012, IIS 7.5 and I'm using Microsoft Visual Studio 2012 Express for Web. I have following code:

@Model.PageItem.Fields["Title"];<br />
@Model.PageItem.Fields["Image"].GetValue(true, true);<br />
@Model.PageItem.Fields["Text"];<br />
Sitecore.Data.Items.MediaItem item = Model.PageItem.Fields["Image"].Item;
@Sitecore.StringUtil.EnsurePrefix('/', Sitecore.Resources.Media.MediaManager.GetMediaUrl(item));<br />

结果很简单:

Result is simple:

Sitecore
<image mediaid="{4DFD3ABC-0BC0-41D2-BD38-705946A1368A}" mediapath="/Images/xbox" src="~/media/4DFD3ABC0BC041D2BD38705946A1368A.ashx" />
<p>Welcome to Sitecore</p> 
/sitecore/shell/~/media/110D559FDEA542EA9C1C8A5DF7E70EF9.ashx

当我浏览到我得到以下错误在最后一行指定的路径:

When I navigate to the path specified in the last line I get following error:

HTTP Error 404.0 - Not Found
The resource you are looking for has been removed, had its name changed, or is temporarily unavailable.

我试过几件事情,例如:

I tried few things, e.g.:

  1. 在Web.config中Media.UseItemPaths改为trye(或虚假) - 实在不行......
  2. Media.RequestExtension在Web.config中设置为空(ashx的默认值)
  3. 在我添加的ashx为允许扩展在Web.config中(因为如果我不能有正常的扩展,我至少希望有工作的ashx链接)
  4. 在我添加的ashx到IIS 7.5 - >请求筛选 - >文件扩展名

当然,每一个变化(以防万一),我重新启动服务器后清除浏览器的缓存(实际上,几个请求后,我有镀铬禁用缓存)。中

Of course after each change (just in case) I restarted server and cleared browser's cache (actually, after few requests I have disabled cache for chrome).

我一直在寻找解决方案,对sdn.sitecore.net,没有运气。其实我已经花了超过300小时,到目前为止寻找解决方案,并不能找出什么错误...任何帮助或建议AP preciated!

I was looking for solution on sdn.sitecore.net with no luck. Actually I've spent more than 3 hrs so far looking for solution and can't figure out what is going wrong... Any help or suggestions appreciated!

推荐答案

在Sitecore.Mvc.Helpers.SitecoreHelper类的现场方法可以让你的输出图像字段。

The Field method of the Sitecore.Mvc.Helpers.SitecoreHelper class will allow you to output an Image field.

下面是一个例子显示,其输出的三个字段渲染:

Here's an example View Rendering that outputs your three fields:

@using Sitecore.Mvc.Presentation
@using Sitecore.Mvc
@model RenderingModel

@Html.Sitecore().Field("Title")<br />
@Html.Sitecore().Field("Image")<br />
@Html.Sitecore().Field("Text")<br />

约翰·韦斯特广泛热议的Sitecore的MVC,你可能会喜欢看他的<一个href="http://www.sitecore.net/Community/Technical-Blogs/John-West-Sitecore-Blog/Posts/2012/06/About-MVC-Helpers-with-the-Sitecore-ASPNET-CMS.aspx"相对=nofollow>关于MVC助手与Sitecore的ASP.NET CMS 的帖子。

这篇关于我怎样才能让Sitecore的显示图像(或其他资源)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆