便携式区域中的嵌入图像在部署时不显示
我在 VS2010 和 IIS 7 上使用 MVC 2。我创建了一个可移植区域,其中嵌入了一些图像。我尝试在可移植区域注册时以两种方式创建路由规则。以下是我尝试过的两种方法。
方法 1
context.MapRoute("ResourceRoute", "login/resource/{resourceName}",
new { controller = "EmbeddedResource", action = "Index" },
new string[] { "MvcContrib.PortableAreas" });
context.MapRoute(
"login",
"login/{controller}/{action}",
new { controller = "login", action = "index" });
RegisterAreaEmbeddedResources();
在这种情况下,我尝试使用 Url.Resource() 访问图像
方法 2
context.MapRoute(
"login",
"login/{controller}/{action}",
new { controller = "login", action = "index" });
RegisterDefaultRoutes(context);
RegisterAreaEmbeddedResources();
在这种情况下,我尝试使用 Url.Content() 访问图像
以下是一切正常的场景。
- 当我在本地开发服务器上运行应用程序时(Ctrl + F5)。
- 将应用程序发布到我的本地主机后运行应用程序时。
- 当我在不同的开发服务器(Ctrl + F5)上运行应用程序时,比如说在我朋友的盒子上。
但如果我在别人的系统上发布,比如我朋友机器上的本地主机,它不会渲染图像(现在我只有图像作为静态资源。没有 CSS 或 JS)。除了图像渲染之外,其他一切都工作正常。
我已经尝试了所有可能的方法来使其在失败的情况下呈现,但一切都是徒劳的。我这里需要一些帮助。请问有人吗?
先感谢您!
I am using MVC 2 on VS2010 and IIS 7. I created a portable area with some images embedded into it. I tried to create routing rule two ways at the time of portable area registeration. Following are the two ways I tried.
Method 1
context.MapRoute("ResourceRoute", "login/resource/{resourceName}",
new { controller = "EmbeddedResource", action = "Index" },
new string[] { "MvcContrib.PortableAreas" });
context.MapRoute(
"login",
"login/{controller}/{action}",
new { controller = "login", action = "index" });
RegisterAreaEmbeddedResources();
In this case I tried to access the image using Url.Resource()
Method 2
context.MapRoute(
"login",
"login/{controller}/{action}",
new { controller = "login", action = "index" });
RegisterDefaultRoutes(context);
RegisterAreaEmbeddedResources();
In this case I tried to access the image using Url.Content()
Following are scenarios where things are working fine.
- When I run the application on my local development server (Ctrl + F5).
- When run application after publishing it on my localhost.
- When I run the application on different development server (Ctrl + F5), say on my friend's box.
But it does not render image (right now I have only images as static resource. No CSS or JS) if I publish on someone else's system, say localhost on my friend's box. Everything else is working fine except for the image rendering.
I have tried all possible means to get it rendered in the situation it is failing but all in vain. I need some help here. Anyone please?
Thank you in advance!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
关于如何处理便携式区域中的嵌入内容,在此 博客文章。
There is a good discussion on how to handle embedded content in portable areas in this blog post.