vran
vran

Reputation: 173

Return config URLs based on Database stored values

Problem trying to solve: Move the URLS from the config and use class type to dynamically substitute the URL. I have one Website configured in IIS with multiple Host Names.

I am working on Art Academy website using .NET Framework WEB API + React (SPA). Students have two option of ClassType - it can be either 1) Dance Or 2) Art

> if Dance is choosen i want them to see URL  - myDomain.classesForDance.com
> else if Art is choosen  i want them to see URL - myDomain.classesforArt.com

Both URL points to same website except change in LOGO and some other minor details which are handled in code based on classType selected by the students

I am trying to resolve how do i go about IIS binding with multiple host names so that i don't have to manage two websites. IIS will have one website where it points to two Host Names as below:

  1. myDomain.classesForDance.com
  2. myDomain.classesforArt.com

In the appSettings.config (web.config) I have URL for various environments like QA, Stage, Prod etc

For example, on QA

What i want to do is, i want to dynamically send back URL like Either LogInUrl=http://login.qa.classesForDance.net/auth?siteCode=DANCE OR LogInUrl=http://login.qa.classesforArt.net/auth?siteCode=ART based on student's class selected as per their profile. Move the URLS from the config and use selected class type to dynamically substitute the URL.

How do i go about solving this problem

Note** System.Web.Hosting.HostingEnvironment won't solve as I can only access properties like SiteName etc. What i need is correct URL based on ClassType students have opted for.

One solution i have thought so far is to come up with a service which first reads the DB and replaces the appSettings.config - config URL based on ClassType. I don't want to add more Keys to AppSettings for another hostname, for example what if i add another classType - singing in future - the design should be able to accommodate easily without much changes in code and simply by adding one more classType in DB - return myDomain.classesforSinging.com

Is there any better or alternative approach someone can suggest? Anything i need to consider while handling this problem?

Upvotes: 2

Views: 97

Answers (0)

Related Questions