0

我将 url 保存在数据库中,并且各个用户都映射到 url

URL: ~/user

从应用程序,我检查通过

bool isAuthorized = DBHelper.IsAuthorized(
string.Concat("~" , Url.Action("Index", "User"), 
httpContext.User.Identity.Name);

它在开发环境中运行良好。但是在生产中,应用程序是在 IIS 应用程序ucms下配置的,因此 Url.Action("Index", "User") 返回,/ucms/user因此isAuthorized返回 false。

任何人都可以就为解决这种行为而进行的更改提供任何意见或方向。

4

1 回答 1

1

在检查之前删除虚拟路径:

var relativePath = yourPath.Remove(0, HttpContext.Current.Request.ApplicationPath.Length);

适用于虚拟目录和域。

于 2013-07-24T21:30:02.660 回答