0

In production we have one external and one internal url to the same website. When using the external url we want the url created by Url.Link() to use the external url but it uses the internal url:

public class DefaultController : ApiController
{

    [HttpGet]
    [Route("api/initialize/{formId}")]
    public async Task<IHttpActionResult> Initialize(Guid formId)
    {
        try
        {
            var url = await _service.GetUrl(formId, Url.Link("Callback",  new { formId }));
            return Redirect(paymentUrl);
        }
        catch (Exception ex)
        {
            Log.Error(ex, ex.Message);
            throw;
        }
    }
}

In another application that can handle external url we use Controller with Url.Action() instead of ApiController with Url.Link():

Url.Action(nameof(Callback), "ControllerName", new { formId}, Request.Url.Scheme));

Why is that?

emst
  • 1
  • 2

0 Answers0