locked
how to get different urls based login? RRS feed

  • Question

  • [Route("{page:regex(^(?!admin$))}/home/Index")]
            [Route("Admin/home/Index")]

    {

    ...

    }

    I have 2 logins,one is admin login and another one is client login..

    if i login as admin the url should be Admin/home/Index

    if i login as client the url should be home/Index(admin should not come)

    so i tried like above code,in client login iam getting this issue admin/home/index.

    can anybody help for this?

    • Moved by Caillen Friday, January 30, 2015 9:09 AM
    Tuesday, January 27, 2015 11:29 AM

Answers

All replies

  • Please post questions related to MVC in the ASP.NET forums (http://forums.asp.net ).
    • Proposed as answer by Caillen Friday, January 30, 2015 9:09 AM
    • Marked as answer by Just Karl Thursday, April 9, 2015 9:45 PM
    Tuesday, January 27, 2015 4:55 PM
  • this question is mvc5 attribute routing question itself.sorry i forgot to give actionresult()

    [Route("home/Index")]
     [Route("Admin/home/Index")]
     public ActionResult Index()

    {

    ....

    }

    I have 2 logins,one is admin login and another one is client login..

    if i login as admin the url should be Admin/home/Index

    if i login as client the url should be home/Index(admin should not come)

    so i tried like above code,in client login iam getting this issue admin/home/index.

    can anybody help for this?

    Wednesday, January 28, 2015 5:04 AM
  • You may be able to use an environmental variable.  Check both logins by opening up a cmd.exe window.  Then type the following

    > Set

    All the environmental variables will be shown.  Compare the two login results to see if there is a setting that you can use.  The problem is to determine if a login is an admin.  A none admin will get an exception that an admin will be allowed to perform.  So maybe performing an operation an if an exception occurs than you are not running under an admin account.  If you don't get an exception than you are running as an admin.


    jdweng

    Wednesday, January 28, 2015 7:24 AM