Note that there are some explanatory texts on larger screens.

plurals
  1. POIssue regarding Setting an alternate controller folder location in ASP.NET MVC
    primarykey
    data
    text
    <p>from here i got a little touch about Setting an alternate controller folder location in ASP.NET MVC. here is the url <a href="https://stackoverflow.com/questions/4372548/setting-an-alternate-controller-folder-location-in-asp-net-mvc">Setting an alternate controller folder location in ASP.NET MVC</a></p> <p>they guide us we can change the namespace and also specify the name space in routine code and these way we can solve it but this above link is not showing how to change or store controller related .cs files in other folder location.</p> <p>suppose i want to store controller in folder called <strong>mycontroller</strong> in root then what i need to do. guide me please. thanks</p> <h2>UPDATE</h2> <p>You can do this using Routing, and keeping the controllers in separate namespaces. MapRoute lets you specify which namespace corresponds to a route.</p> <p>Example</p> <p>Given this controllers</p> <pre><code>namespace CustomControllerFactory.Controllers { public class HomeController : Controller { public ActionResult Index() { return new ContentResult("Controllers"); } } } namespace CustomControllerFactory.ServiceControllers { public class HomeController : Controller { public ActionResult Index() { return new ContentResult("ServiceControllers"); } } } And the following routing routes.MapRoute( "Services", "Services/{controller}/{action}/{id}", new { controller = "Home", action = "Index", id = UrlParameter.Optional }, new string[] { "CustomControllerFactory.ServiceControllers" } // Namespace ); routes.MapRoute( "Default", // Route name "{controller}/{action}/{id}", // URL with parameters new { controller = "Home", action = "Index", id = UrlParameter.Optional }, new string[] { "CustomControllerFactory.Controllers"} // Namespace ); </code></pre> <p>You should expect the following responses</p> <pre><code>/Services/Home ServiceController /Home Controllers </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload