0

I have code like below

[RouteArea("Client")] 
public Class LoginController : Controller {
    [Route("register")]
    public ActionResult SignUp() {
        return View();
    }
}

Attribute routing unfortunately is not working in the areas :/, if I will remove "register" route for signup, it will work just for for client/signup, but with route "register" it is not working.

I have added [RouteArea()], tried with [RoutePrefix] but nothing is working correctly "Route Area" just enabled to use it with views (before that Razor couldn't find the view).

What am I doing wrong ?

1 Answer 1

1

Ok I HAVE FOUND THE SOLUTION.

1 Remove Area registration class from your area

2 Use this convention :

[RouteArea("Client")]
[RoutePrefix("login")]
[Route("{action}")]
public class LoginController : Controller
{

    [Route("")]
    // GET: Client/Login
    public ActionResult Index()
    {
        return View();
    }

    [Route("register")]
    // GET: client/login/register
    public ActionResult SignUp()
    {
        return View();
    }
}

Now you can use any route you want, with any prefix :)

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.