I have a client who has a huge site that would better serve their visitors if split up into two separate sites. So now I'm trying to split it up, while still sharing certain files between the two (essentially, the only thing that changes is the navigation and pages; the header, footer, and styling should all be the same between the two sites).
So now I am trying to create an If Else statement in ASP.net and VBScript that will switch out certain elements based on what the site's root file path/url is going to be. So far, it looks something like the following:
<% If objPage.FilePath = "/" Then %>
Show Content A
<% Else %>
Show Content B
<% End If %>
Which doesn't really help me as it only seems to effect the home page and not the other site pages. How might I change it to trigger based off the site address or, failing that, is there a variable I can stick in the quotes that will affect not just the root files, but all the subpage files as well?
Also, is there a better way to be going about this?
答案 0 :(得分:0)
如何设置定义风味的web.config设置?
例如:
<appSettings>
<add key="SiteFlavour" value="site1" />
<!--<add key="SiteFlavour" value="site2" />-->
</appSettings>
然后只需替换条件
objPage.FilePath = "/"
使用基于配置设置的测试?
这样做的另一个好处是可以使测试更容易,因为您不依赖于特定的URL。
这也使得第三种口味非常直接。
如果有帮助,您可以随时在应用启动(global.asax?)中从配置中提取设置。