Reputation: 4809
I am saving url's in database and respective users are mapped to the url
URL: ~/user
From application, I am checking via
bool isAuthorized = DBHelper.IsAuthorized(
string.Concat("~" , Url.Action("Index", "User"),
httpContext.User.Identity.Name);
It works well in development environment. But in production, application is configured under a IIS application ucms, so Url.Action("Index", "User") is returning /ucms/user
henceisAuthorized
is returning false.
Could anyone provide any inputs or direction on the changes to be done to tackle this behaviour.
Upvotes: 0
Views: 232
Reputation: 101150
Remove the virtual path before checking it:
var relativePath = yourPath.Remove(0, HttpContext.Current.Request.ApplicationPath.Length);
Works both for virtual dirs and domains.
Upvotes: 1