Note that there are some explanatory texts on larger screens.

plurals
  1. POstatic routing returning 404?
    primarykey
    data
    text
    <p>I'm trying to create a static route as follows:</p> <pre><code>public static void RegisterRoutes(RouteCollection routes) { routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); routes.MapRoute( name: "Hire", url: "Hire/{gender}", defaults: new { controller = "Hire", action = "Index" } ); routes.MapRoute( name: "Default", url: "{controller}/{action}/{id}", defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional } ); } </code></pre> <p>however, when I try access /Hire/Female, for instance, IIS throws a 404 error, as I was reading about routing I noticed routes are usually written as {controller}/{action}/{something}, is it mandatory to have {controller} and {action} on my route?</p> <p>here's the code for the controller:</p> <pre><code>public class HireController : Controller { [HttpGet] public ActionResult Index(string gender) { return View(); } } </code></pre> <p>and I have a file named /Views/Hire/Index.cshtml</p> <p>what I was trying to achieve is to route requests from /Hire/Male and /Hire/Female to the Index action of my HireController but I have the feeling I'm forgetting something since I've tried in different ways and always have a 404 returned</p> <hr> <h1>Update 1</h1> <p>I installed the RouteDebugger from <a href="http://www.codeproject.com/Articles/299531/Custom-routes-for-MVC-Application" rel="nofollow">http://www.codeproject.com/Articles/299531/Custom-routes-for-MVC-Application</a> and it just shows the "basic" routes from MVC ({resource}.axd/{*pathInfo} and {controller}/{action}/{id}), it doesn't show the route I mapped</p>
    singulars
    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.
    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