ASP.NET MVC:生成缩略图时出现问题...需要帮助!

发布于 2024-08-29 18:01:38 字数 410 浏览 1 评论 0原文

好的,我是 ASP.NET MVC 新手,我正在尝试制作一个 Web 应用程序照片库。我已经在这里发布过一次关于这个问题的文章,我试图在页面上动态生成缩略图而不是实际的全尺寸图像。基本上,我正在寻找的功能是能够在页面上显示缩略图,然后能够单击图像以查看全尺寸版本。我正在从 XML 文件中提取图像和图像信息。所以,我这样做是为了动态显示它们,这样以后进行更改会更容易。稍后,我将添加将新图像上传到特定画廊的功能(当我弄清楚如何做到这一点时)。我提供了一个下载我正在开发的项目的链接,以便您可以查看代码。我将不胜感激任何帮助!谢谢! 项目 URL:http://www.diminished4th.com/TestArtist.zip 瑞安

Ok, so i'm new to asp.net mvc and i'm trying to make a web application photo gallery. I've posted once on here about this issue i am having of trying to generate thumbnails on-the-fly on the page instead of the actual full-size images. Basically, the functionality i am looking for is to be able to have thumbnails on the page and then be able to click the images to see the full-size version. I am pulling the images and images info from an XML file. So, i did this so i could display them dynamically and so it would be easier to make changes later. Later, i am going to add functionality to upload new images to specific galleries (when i figure out how to do that as well). I am providing a link to download the project i am working on so you can see the code. I would appreciate any help with this! Thanks!
URL to project: http://www.diminished4th.com/TestArtist.zip
Ryan

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

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

发布评论

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

评论(1

自找没趣 2024-09-05 18:01:38

在您的 global.asax.cs 文件中,您已在 Thumbs 路由之前定义了 Default 路由,因此 url 的 Galleries 部分会映射到不存在的 Galleries 控制器Gallery 控制器的(如第二个路由中指定的):

routes.MapRoute(
    "Default", // Route name
    "{controller}/{action}/{id}", // URL with parameters
     new { controller = "Home", action = "Index", id = UrlParameter.Optional } // Parameter defaults
);

routes.MapRoute(
    "Thumbs", // Route name
    "Galleries/getThumb/{image}", // URL with parameters
     new { controller = "Gallery", action = "getThumb", id = UrlParameter.Optional }, // Parameter defaults
      new string[] { "TestArtist.Controllers" }
 );

只需在 Default 路由之前定义 Thumbs 路由,就可以了:

routes.MapRoute(
    "Thumbs", // Route name
    "Galleries/getThumb/{image}", // URL with parameters
     new { controller = "Gallery", action = "getThumb", id = UrlParameter.Optional }, // Parameter defaults
      new string[] { "TestArtist.Controllers" }
 );

routes.MapRoute(
    "Default", // Route name
    "{controller}/{action}/{id}", // URL with parameters
     new { controller = "Home", action = "Index", id = UrlParameter.Optional } // Parameter defaults
);

In your global.asax.cs file, you have defined the Default route before your Thumbs route so the Galleries part of the url is mapped to a non-existent Galleries controller instead of the Gallery controller (as specified in your second route):

routes.MapRoute(
    "Default", // Route name
    "{controller}/{action}/{id}", // URL with parameters
     new { controller = "Home", action = "Index", id = UrlParameter.Optional } // Parameter defaults
);

routes.MapRoute(
    "Thumbs", // Route name
    "Galleries/getThumb/{image}", // URL with parameters
     new { controller = "Gallery", action = "getThumb", id = UrlParameter.Optional }, // Parameter defaults
      new string[] { "TestArtist.Controllers" }
 );

Simply define the Thumbs route before the Default route and you should be all good:

routes.MapRoute(
    "Thumbs", // Route name
    "Galleries/getThumb/{image}", // URL with parameters
     new { controller = "Gallery", action = "getThumb", id = UrlParameter.Optional }, // Parameter defaults
      new string[] { "TestArtist.Controllers" }
 );

routes.MapRoute(
    "Default", // Route name
    "{controller}/{action}/{id}", // URL with parameters
     new { controller = "Home", action = "Index", id = UrlParameter.Optional } // Parameter defaults
);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文