2

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

  • SignInUrl="http://login.qa.classesForDance.net/auth?siteCode=DANCE"
  • AuthenticationDomain=".qa.classesForDance.net"

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?

vran
  • 163
  • 3
  • 11
  • i have started to play with Configuration Manager where i retrieve all the AppSettings Config, and planning to replace domain based on User selected Class Type The problem i am facing right now is, ConfigucationManager.AppSettings[key] is static - It doesn't have context to User and ClassType - any idea how do i go about solving that issue? For me to get classType - i need to execute DB query and retrieve it from database – vran Mar 16 '21 at 17:31
  • I think the URL Rewrite module in IIS can also be used to modify the URL. – Ding Peng Mar 17 '21 at 05:09
  • not sure how that will solve the problem. Issue is not just to modify the URL, its more like how do we solve based on stored value in Database and return those URLS so that we can avoid configs – vran Mar 18 '21 at 13:31

0 Answers0