问题描述
认为这是一个请求发送到该路径:
的http://域名/用户/ 1534
这个URL是在公安,所以每个人都可以看到它没有在现场被验证(而不登录)。
现在考虑另一个URL应该是安全的:
的http://域名/管理/更新用户
此URL是否通过认证过程。
现在,在我的code,冥冥中我需要知道,如果当前的路径是一个安全的路径,或者没有(请不要问为什么,也可以通过安全的路径我并不意味着SSL,我刚才谈到需要哪些登录路径)。
我怎么能知道 HttpContext.Request.Url.AbsolutePath
是一个安全的路径?
更新:我需要的是这样的:
SecurityHelper.ShouldCurrentRequestPathBeAuthenticated(Request.Url.AbsolutePath)
这要看你如何实现授权过程。某处你需要定义它,所以这就是你如何知道它是否安全路径。
标准ASP.NET会在这种情况下使用该位置/安全设置。
如果您使用标准的认证/授权
那么我相信你可以使用 CheckUrlAccessForPrincipal 。
UrlAuthorizationModule.CheckUrlAccessForPrincipal(virtualPath,用户动词);
Consider that a request is sent to this path:
http://domain/users/1534
This URL is in public security, so everyone can see it without being authenticated in the site (without being logged in).
Now consider that another URL should be secure:
http://domain/admin/update-user
This URL should pass the authentication process.
Now, In my code, somewhere I need to know if the current path is a secure path or not (please don't ask why, and also by secure path I don't mean SSL, I'm just talking about paths for which login is required).
How can I know that HttpContext.Request.Url.AbsolutePath
is a secure path?
Update: What I need is something like:
SecurityHelper.ShouldCurrentRequestPathBeAuthenticated(Request.Url.AbsolutePath)
It depends on how you implement the authorization process. Somewhere you will need to define it, so that's how you know if it's secure path.
Standard ASP.NET would use the location/security settings in this case.
If your using standard authentication/authorization
then I believe you can use CheckUrlAccessForPrincipal.
UrlAuthorizationModule.CheckUrlAccessForPrincipal(virtualPath, user, verb);
这篇关于如何知道,如果当前路径是一个安全的路径或没有,在ASP.NET的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!