3

I'm messing about with controller organisation and I've hit a problem.

If I have the following physical structure

/Home/HomeController.cs
/Home/Index.aspx
/Home/About.aspx

and I request the URI:

/Home/Index

I get a 403 Directory Listing Denied :(

(im using a custom IControllerFactory and IViewEngine to look in this non-default path)

Why is this happening? (I know the 403 is because its hitting the /Home folder, but why is it hitting the folder?)

Why doesn't the UrlRoutingModule rewrite the route and let the controller pick up the request?

Application_BeginRequest fires, but then it seems to pass control back to IIS to try and serve from the filesystem.

Is it the UrlRoutingModule that defaults to a physical path if it exists before rewriting?

Is there a way to make this work?

N.B. Please don't suggest relocating my controllers etc. I know this is an obvious option, but that isn't the question ;)

Using IIS7 In Integrated Mode

Thanks

2 Answers 2

4

Because the routing abstraction will only route a request that has no equivalent file on disk.

You have no other option but to rename your folder structure.

-- Edit No, actually you can disable that "feature" by setting the RouteExistingFiles property on RouteCollection.

Sign up to request clarification or add additional context in comments.

1 Comment

then css files not loading
1

The routing module does, indeed, have a preference for real files if they exist. It seems that it must also not reroute after a failed accessibility check.

You do get the point that having separate controller/views reinforces the separation of concerns central to an MVC architecture, right? I'd be concerned that keeping controllers/views in the same folder might confuse things for later developers.

2 Comments

hmm do you know where this "preference" code lives? i went on a reflector safari but a lion eated me :(
System.Web.Routing.RouteCollection.GetRouteData(HttpContextBase)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.