views:

42

answers:

4

Hey guys,

I will try and be brief, I am finding when trying to create a custom route with a name and url of properties that my ASP.NET MVC app is returning a 404 file not found when hitting the route.

I have deduced this down to most likely be caused by the fact I have a folder on disk called Properties which is of course a common asp.net folder which is automatically created. I have found someone else who has suffered from this problem on SO, but looks like there has been no resolution, only to name your route something different!

Surely this is an oversight, or there must be a workaround? Obviously there will be many common directories you may need as routes and/or folders interchangeably, some of which we already know like Properties probably can't be deleted! I also understand we need to honor real folders as URLs too, but I feel routing should take priority before looking at folders on disk.

If someone has any ideas on how to accomplish this it would be greatly appreciated. :)

A: 

No way around it. Sorry.

bortao
Downvoted for not being an actual answer, use comment next time..
bleevo
A: 

I am not sure but does this help?

http://haacked.com/archive/2010/04/29/allowing-reserved-filenames-in-URLs.aspx

bleevo
Hey did see this post, bit diffedrent, but tried it just for kicks. Didn't work as it addresses more virtual 'reserved words' I suppose rather than hard physical directories getting in the way.
GONeale
+1  A: 

Looking at the .NET reference source code, it doesn't appear as if Properties is special to the ASP.NET runtime (HttpRuntime.cs has string constants for bin, App_Code, etc.).

Try renaming the physical Properties folder to something like App_Properties and editing the namespace of the files in there to match. You'll also need to edit the .csproj / .vbproj file too, since VS hides the Rename command for this "special" folder.

Once you've done this, using some of the built-in behaviour in the project property tabs such as creating default settings and resources will cause the Properties folder to be recreated so you'll have to open the .settings and .resx files directly to edit them.

devstuff
Interesting concept, will try.
GONeale
Worked great, thanks
GONeale
+1  A: 

If you remove the properties folder in your asp.net mvc project it will work as described.

It should be noted that the behavior you are describing will not present itself when running under IIS (not that this is actually a solution).

IISExpress should help when it is released!

I would like to experiment with this more as I thought the route engine took precedence over file system objects, esp when you setup a wild card mapping.

bleevo