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
+1
A:
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
);
Bermo
2010-04-22 10:57:01