c# - Making a controller not visible to the client in ASP.NET WEB API (or MVC) -


let's suppose have layer of abstract controllers, delegates request child controller class, until reaches implementation.

think of pipeline of controllers, request must go through, , includes caching responses, authorizing , authenticating user, validating input , output data, handling repository access, etc.

my leaf class (the last child of hierarchy), may have following signature:

public class seasonscontroller : defaultpersistencerestcontroller                                  <int, season, seasonputdto, seasonpostdto, seasonquerydata> {       /** controller implementation here  **/ } 

the base classes have lot of reusable code located in 1 module, , has helped me lot when changing logic of controllers @ global level.

now, suppose seasonscontroller need call episodescontroller, irrelevant reasons.

the call this:

episodescontroller episodecontroller = new episodescontroller(); //do episodescontroller 

the problem don't want episodescontroller accessed outside, such client's request. asp.net automatically identifies controllers , creates public endpoint them, such http://localhost:80/episodes.

i created episodescontroller because uses lot of logic controller's base classes, intend use internally.

i can desactivate authentication, authorization, cache , other stuff useless if controller used in way, that's not problem.

however, cannot manage prevent asp.net ignore episodescontroller class, , not consider controller.

is there attribute or annotation maybe tell compiler this? maybe modification in web.config?.

also note don't want change episodescontroller's class name name, controller, internal one.

you try use ignoreroute extension method. or try internal suggested beautifulcoder. if it's in assembly (and can modify it) make visible other assemblies internalsvisibletoattribute.

although honest, using 1 controller within controller doesn't seem right me. try , refactor common functionality services/helpers, make episodescontroller simple service. composition on inheritance , :)


Comments

Popular posts from this blog

java - Plugin org.apache.maven.plugins:maven-install-plugin:2.4 or one of its dependencies could not be resolved -

Round ImageView Android -

How can I utilize Yahoo Weather API in android -