The location path used with the MVC application does not work

I want to use the location path, allow the user and prevent the user from restricting access in my MVC application. This is the section I added in web.config

<location path="Views/Admin/Ticketing/Seasons.aspx"> <system.web> <authorization> <allow users="admin" /> <deny users="user1" /> </authorization> </system.web> </location> 

He does not work. non-admin users, such as user1, can view the page. I am not sure if this is because I have the routing setup different or wrong.

This is the URL of the tab I want to block.

http: //marilyndenisservices.localhost/Admin/TicketingSeasons

This is the physical path of this page on disk D: \ DEV \ MarilynDenisServices \ SRC \ Web \ Views \ Admin \ Ticket \ Seasons.aspx

And this is how I tuned it to a view model

 <div id="menucontainer"> <ul id="menu"> <li><%= Html.ActionLink("Ticketing", "TicketingSeasons", "Admin") %></li> </ul> </div> 

This is my action

 public ActionResult TicketingSeasons() { return View("Ticketing/Seasons"); } 

Can someone tell me what I'm doing wrong?

+7
authorization web-config asp.net-mvc-4
source share
1 answer

Try this way:

 <location path="Admin/TicketingSeasons"> <system.web> <authorization> <allow users="admin" /> <deny users="user1" /> </authorization> </system.web> </location> 
+21
source share

All Articles