Different url based on development environment with C# MVC

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

    What if you made the Model for the MVC View a Dictionary or added a dictionary of settings to the Model returned and simply returned the data from the controller?

    Contact Us
    

    OR

    Contact Us
    

    Alternatively you could just use a Model that has a ContactUsUrl property

    Contact Us
    

    Then in your controller code you could use whatever logic you want to decide whether it is DEV, QA or PROD and pull the data for the URL from the associated source, e.g. a database, a config file, a custom settings file. This abstracts the logic and simplifies how your data is used on the page.

    This is an alternative to using the web.config directly.

提交回复
热议问题