Different url based on development environment with C# MVC

后端 未结 7 1624
眼角桃花
眼角桃花 2021-02-15 14:25

I have two MVC web applications, a www.company.com and a solution.company.com

The website www.company.com include links to solution.company.com/Contact but how can I set

7条回答
  •  离开以前
    2021-02-15 15:09

    You don't need to use app settings for this. Just use the URLHelper that's part of MVC and it'll ensure that the correct hostname is used.

    So instead of this:

    Contact Us 
    

    You do this:

    Contact Us
    

    That will generate a link that points to the Contact action within the IndexController.

    Another option is to use the HTMLHelper extension method to generate the entire tag for you. In that case, you'd do this:

    @Html.ActionLink("Index", "Contact", "Contact Us")
    

提交回复
热议问题