Reputation: 33850
In my controller action, I have the following code:
...more code
if (...)
{
// create a site user
await this.CreateUserAndSignHimInAsync(UserType.SiteUser, model);
var landingPageUrl = IdentityManager.GetLandingPageUrl(model.Email);
return Redirect(landingPageUrl);
}
...more code
The landingPageUrl
is a url that looks like so: "~/Journal/Search".
At the return Redirect
line, I get an exception that says:
The relative virtual path '~Journal/Search' is not allowed here.
Upvotes: 1
Views: 7076
Reputation: 33850
The problem with my code was that the URL that I was trying to redirect to, as reported by the exception message, was an ill-formed ~Journal/Search instead of ~/JournalSearch.
Also, I discovered that if you have an ASP.NET virtual relative URL like "~/Journal/Search" and you would like to turn it into an absolute Url, you can call the UrlHelper.GenerateContentUrl
static method like so:
var url= UrlHelper.GenerateContentUrl("~/Journal/Search",
Request.RequestContext.HttpContext);
Upvotes: 1