与MVC应用程序中使用位置路径不起作用 [英] location path used with MVC app doesn't work

查看:143
本文介绍了与MVC应用程序中使用位置路径不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用的位置路径,允许用户和拒绝用户限制我的MVC应用程序的访问。这是我添加到web.config

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>

这是行不通的。非管理员用户,比如用户1仍然可以查看页面。我不知道这是否是因为我有路由设置不同的或者错误的。

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

这是在磁盘上的页面的物理路径
D:\\ dev的\\ MarilynDenisServices的\\ src \\网络\\视图\\管理\\售票\\ Seasons.aspx

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>

这是我的行动

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

谁能告诉我什么,我做错了什么?

Can someone tell me what I am doing wrong?

推荐答案

试试这个位置路径:

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

这篇关于与MVC应用程序中使用位置路径不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆