0

I have take over a web application and it has the web api and mvc controllers separated into two projects. The Web Api website has its own base api url localhost:0000 and the mvc website as localhost:1111. I am generating a click through link that goes out in an email with the intent to return the user to registration page which is on the mvc website. Right now my only option is to do this from the webApi controller however when I generate a link using Url.Link or Url.Content I always get the WebApi localhost:0000 url. How do I get the MVC localhost:1111 Url?

-- I left my original question as is --

I think I need to explain this one more clearly... sorry

I am generating a Url on my WebApi controller in a website with the url 'localhost:0000' doing something like this

invite.ReturnUrl = Url.Link("defaultApi", new { controller = "Account", action = "Register", icode = invite.Id});

OR

invite.ReturnUrl = Url.Content("/Account/Register?icode=" + invite.Id);

I want the created url, however, to use my projects MVC website's base url of "localhost:1111"

How do I go about this?

1 Answer 1

0

It's not that elegant... but this should work:

invite.ReturnUrl = new UriBuilder(Request.RequestUri.Scheme, Request.RequestUri.Host, 1111, "myApplication/Account/Register?icode=" + invite.Id).ToString();
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.