asp.net mvc - How to disable or reprioritize IIS DirectoryListingModule under MVC module? -
I use an MVC folder structure where the URL matches the directory names, such as:
< Pre> & lt; Proj & gt; The URL needs to be accessible by the \ My \ Cool \ Thing \ ThingController.cs
http: //blahblah / my / cool / Thing
I have MVC routing work, but unfortunately when the default depends on {action} & amp; {ID}, IIS Express routing requests instead of DirectoryListingModule, because it directly matches a folder name. Directory listing is objected so that instead of me:
The web server is configured not to list the contents of this directory. Module DirectoryListingModule Notification ExecuteRequestHandler Handler StaticFile
I have already tried to fix this:
1. RunAllManagedModulesForAllRequests = true & lt; System.webServer & gt; & Lt; Run the moduleAll managed modules FOR ALLRequests = "true" & gt; // No matter 2. module & lt; System.webServer & gt; & Lt; Run the moduleAll managed modules FOR ALLRequests = "true" & gt; & Lt; Remove name = "DirectoryLosting module" /> // I will not let the IIS lock as a module & lt; / Modules & gt; & Lt; /system.webServer> 3. Lock & amp; Module // applicationhost.config & lt; Add name = "DirectoryListingModule" lockItem = "false" /> // web.config & lt; Name = "DirectoryListingModule" / & gt; Remove // due to the startup error "handler" staticfile "has a bad module" DirectoryListingModule "in its module list" 4. Lock & amp; To delete / read the module (to change the order) - no difference / web Config & lt; Delete name = "DirectoryListing module" /> & Lt; Add name = "directory listing module" />
Throwing Out My Hair How can I route IIS to my MVC app instead of DirectoryListingModue ?? Probably one solution in web.config so we do not need to reconfigure IIS in production.
(A functioning is to keep my folder structure, but break it between all the fields / regions / ... instead of the folder path and the URL to store. This is a terrific hack And the last resort is.)
Edit to add route mapping
I am creating custom paths corresponding to each controller's namespaces (namespace is always folders ) Note that to avoid the problem described above, everything is currently kept under the "Module" namespace / folder.
Private Static Zero Registration All Controllers (Route Collection Routes) {const String Controlsfix = "Controller"; Const String NamespacePrint = "My.Cool.Websire.UI.Modules."; Var Controller Type = Assembly. Gate Contingency Assembly (). GetTypes () Where (x = & gt; x.IsSubclassOf (type (controller)). ToList (); Foreach (Miscellaneous controller type in controller type) {// Turn to My.Cool.Website.UI.Modules.XYZAbc.AbcController url / X / Y / Z / ABC / {action} / {id} var fullNamespace = Controller type Namespace for a root ?? ""; Var relativeNamespace = fullNamespace.Substring (name spacefix length, full name. Length - namespacefix.leng); Var Controller Name = Controller Type: Name. Editing (AdminSaffix) with? Type the controller. Name Substring (0, Type Controller. Length - Controller Sufix.Length): Controller Type. Name; Var url = relativeNamespace.Replace (".", "/") + "/ {Action} / {id}"; Var Route = "Dedicated" + Controller Name + "Route"; Routes MapRoute (route name, URL, new {controller = controller name, action = "index", id = url parameter. Optional}); My solution at this stage is to keep the MVC content of the WebUI project A / Under Module / Folder: My.Cool.Site.WebUI / Module / Some / Blah / Blah Controller My.Cool.Site.WebUI / Module / Some / Blah / Scene / .. . After posting the root code, I can access it via url: mile.site.webi / module / some / blah / partial view / ... http: //.../Something/Blah/ [action]
Because under files / modules / folder, this is between the URL and the folder Match breaks the path which gets around my problem.
Not a great solution but works.
Comments
Post a Comment