Different url based on development environment with C# MVC

后端 未结 7 1619
眼角桃花
眼角桃花 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:00

    From what you can see in the already existing answers, you're going to need to change your static string hrefs for something defined in compile time. I think you should follow the previous advises and write different tags for the Web.Debug.config and the Web.Release.config, but not to solve your specific situation, mostly to define your connection strings in case you have different database sources for each base.

    To solve your specific situation, just use the Url native MVC helper, and replace your static hrefs for something like, Contact , where "~/" stands for your domain root, regardless of which one it is.

    Also, given you didn't write any Controller name before "Contact", I'm assuming you have a ContactController in your application and is reaching its Index View with this address.

提交回复
热议问题