I have been playing around for quite a while now with the MVC Routing classes and have implemented a near perfectly working alternative solution for url rewriting.
One last issue to overcome is the following:
When you want to route from http://myurl.com/animals to http://myurl.com/themehome.aspx?category=animals this is only possible if there is no existing
~/animals folder. If there is one, the link will automatically open the standard 'Directory Listing'-page instead of going through the routing logic.
Does anyone have any idea to get around this without renaming this folder 'animals' into something else?
Thanks a lot!
Peter
MVCroutingdirectory listingurl rewriting
Don't forget to click "Mark as Answer" on the post(s) that helped you. This credits that member, earns you a point and marks your thread as Resolved.
Pinky: Hmmm... let me think...
Brain: Don't hurt yourself, Pinky.
By default, DirectoryListingModule take precedence over UrlMappingsModule. Fortunately, it is possible to change the order of UrlMappingsModule and DirectoryListingModule.
Goes to IIS7 Manager -> Modules, in the right pane, click View Ordered List, you can then use Move Down, Move Up to change the order of modules.
Zhao Ji Ma
Sincerely,
Microsoft Online Community Support
“Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread. ”
Marked as answer by Peter Meir on Apr 24, 2008 04:37 PM
Thanks Zhao Ji Ma that helps a lot and solved my issue!
Although I don't have access to the production database, I know now how it can be solved.
Don't forget to click "Mark as Answer" on the post(s) that helped you. This credits that member, earns you a point and marks your thread as Resolved.
Pinky: Hmmm... let me think...
Brain: Don't hurt yourself, Pinky.
Goes to IIS7 Manager -> Modules, in the right pane, click View Ordered List, you can then use Move Down, Move Up to change the order of modules.
This is almost exactly what I need.
Do you know if this is possible only from within the web.config? I have the same problem, but don't have access to IIS Manager, as it is a shared server.
Thanks for your first answer, and hopefully for this one as well!
Peter Meir
Member
15 Points
8 Posts
MVC URL Routing overrides Directory Listing
Apr 22, 2008 08:01 AM|LINK
Hi,
I have been playing around for quite a while now with the MVC Routing classes and have implemented a near perfectly working alternative solution for url rewriting.
One last issue to overcome is the following:
When you want to route from http://myurl.com/animals to http://myurl.com/themehome.aspx?category=animals this is only possible if there is no existing ~/animals folder. If there is one, the link will automatically open the standard 'Directory Listing'-page instead of going through the routing logic.
Does anyone have any idea to get around this without renaming this folder 'animals' into something else?
Thanks a lot!
Peter
MVC routing directory listing url rewriting
Pinky: Hmmm... let me think...
Brain: Don't hurt yourself, Pinky.
Zhao Ji Ma -...
All-Star
23104 Points
2380 Posts
Re: MVC URL Routing overrides Directory Listing
Apr 24, 2008 12:18 PM|LINK
Hi Peter,
By default, DirectoryListingModule take precedence over UrlMappingsModule. Fortunately, it is possible to change the order of UrlMappingsModule and DirectoryListingModule.
Goes to IIS7 Manager -> Modules, in the right pane, click View Ordered List, you can then use Move Down, Move Up to change the order of modules.
Sincerely,
Microsoft Online Community Support
“Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread. ”
Peter Meir
Member
15 Points
8 Posts
Re: MVC URL Routing overrides Directory Listing
Apr 24, 2008 04:39 PM|LINK
Thanks Zhao Ji Ma that helps a lot and solved my issue!
Although I don't have access to the production database, I know now how it can be solved.
Pinky: Hmmm... let me think...
Brain: Don't hurt yourself, Pinky.
adraper
Member
5 Points
5 Posts
Re: MVC URL Routing overrides Directory Listing
Jul 06, 2012 05:26 PM|LINK
This is almost exactly what I need.
Do you know if this is possible only from within the web.config? I have the same problem, but don't have access to IIS Manager, as it is a shared server.
Thanks for your first answer, and hopefully for this one as well!
RealStoggy
Member
2 Points
1 Post
Re: MVC URL Routing overrides Directory Listing
Jul 13, 2012 01:19 AM|LINK
Hi,
what about "routes.RouteExistingFiles"?? More information: http://msdn.microsoft.com/EN-US/library/cc679949(v=vs.100).aspx
Regards
adraper
Member
5 Points
5 Posts
Re: MVC URL Routing overrides Directory Listing
Jul 13, 2012 02:51 PM|LINK
That doesn't work if you still want the contents of the existing folders to be served if they exist.
routes.RouteExistingFiles = true will not serve the existing files.
routes.RouteExistingFiles = false will not serve the "Animals" route in Peter's example... it will attempt to show the directory listing.