0

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.

1

1 Answer 1

1

Remove the virtual path before checking it:

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

Works both for virtual dirs and domains.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.