This project is read-only.

Adding an .aspx or MVC controller to the root app

Jan 16, 2011 at 11:01 AM

The great thing about ASP.NET MVC was that it worked side-by-side with Web Forms. Unfortunately, with Orchard installed if I create an .aspx file or create a Controllers directory and add a controller file I just get 404.

How can I add an .aspx file to the root of the site such that it would execute the old fashioned way?

How can I add an MVC controller to handle specific routed events?

If it doesn't work, what would it entail to make it work?

Jan 16, 2011 at 2:57 PM

Your best bet is to create a module, which is logically equivalent to an MVC Area, and then add in  a Routes class in the root of the module which implements IRouteProvider (which is again, logically equivalent to the route stuff in the area startup

Jan 16, 2011 at 3:35 PM
Edited Jan 17, 2011 at 8:34 PM

When using the “Web” distribution (rather than “Source”), when I right-click the project node in the solution explorer I don’t get the “Add Area” option. Am I missing something? I do have ASP.NET MVC 2 and ASP.NET MVC 3 installed w/ VS tooling. 

I won’t use “Source” distribution because that puppy emits half a gigabyte of a published site when publishing. 


Jan 17, 2011 at 8:42 PM
Edited Jan 17, 2011 at 8:43 PM

So as no one answered I'll just post the answer I found. Use orchard.exe to generate the module project, as documented here:

Be sure not to go into Solution Explorer and add the generated files to the Orchard project, as I made the mistake of doing. Doing and then undoing this may have caused this to happen, too:

Jan 17, 2011 at 8:52 PM

The root web.config of the application is locked down for security, but if necessary you can go in there and relax it a bit. In particular, look at the disabled handlers. To maintain good separation and security, I'd recommend putting the webforms pages into a separate directory and only re-enabling things from a web.config inside of the directory. That is what we did for static content folders.