location path used with MVC app doesn't work

天涯浪子 提交于 2019-12-04 11:54:04

问题


I want to use the location path , allow user and deny user to restrict access in my MVC app. This is the section that I added to the web.config

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

It is not working. non-admin users, like user1 can still view the page. I am not sure if it is because I have the routing set up differently 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\Ticketing\Seasons.aspx

And this is how I configured it on the 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 am doing wrong?


回答1:


Try this location path:

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


来源:https://stackoverflow.com/questions/18217979/location-path-used-with-mvc-app-doesnt-work

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!