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?

Mark Hollas
  • 1,107
  • 1
  • 16
  • 44

1 Answers1

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();
Borophyll
  • 1,099
  • 2
  • 15
  • 24