显示基于生产服务器的菜单页面的条件 [英] Condition that displays menu page based on production server

查看:92
本文介绍了显示基于生产服务器的菜单页面的条件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个主菜单页面,在标题中显示单词TEST。



页面的其余部分包含指向网站上不同页面的链接。 br />


当我将页面移动到生产服务器时,我不希望工作TEST显示在标题中。



测试服务器和生产服务器共享相同的IP地址,但端口不同。



我尝试使用System.Web.HttpContext.Currrent.Request。 UserHostAddress;但这不起作用。





如何在主菜单页面上写一个条件,这样如果工作TEST不显示服务器是生产服务器吗?



我尝试过:



我试过System.Web.HttpContext.Current.Request.UserHostAddress

I have a main menu page that displays the word TEST in the header.

The rest of the page includes links to the different pages on the website.

When I move the pages to the Production server, I do not want the work TEST to display in the header.

The test server and production server share the same IP address but the ports are different.

I tried using System.Web.HttpContext.Currrent.Request.UserHostAddress; but this did not work.


How can I write a condition on the main menu page so the work TEST does not display if the server is the Production server?

What I have tried:

I have tried System.Web.HttpContext.Current.Request.UserHostAddress

推荐答案

设置应用程序设置key =environmentTitlevalue =TEST

并在页面上显示。

你会知道它是对还是错,因为你会看到TEST或其他东西。

如果你期望的话看到一些文字,但看不到它,这意味着配置是错误的。



虽然我以前亲自在小型应用上做过这个,但更好的解决方案是有一个测试虚拟目录,例如http://my.site.com/testSite,您可以根据需要轻松检查代码中的路径。
Set an application setting key="environmentTitle" value="TEST"
and show that on the page.
You will know if it's right or wrong as you will see "TEST" or something else.
And if you expected to see some text but don't see it, it means the config is wrong.

Although I have personally done this before on small apps, a better solution would be to have a test virtual directory e.g. http://my.site.com/testSite and you can inspect the path in the code as well just as easily if you ever want to.


在appsettings中为配置添加值。使用config transform然后说,当在生产模式下部署时,在页面的服务器端请求中使用此值将其传递给UI。



这是一个我相信很多人可以选择你想要的东西。



你的开发web.config。



Add a value to your config in appsettings. Use config transform to then say, when deployed in production mode, use this value within the server side request for the page to pass it to the UI.

This is one option of I am sure many to imeplemnt what you are looking for.

Your development web.config.

<appSettings>
    <add key="Environment" value="TEST" />
</appSettings>





你的web.release.config





Your web.release.config

<appSettings>
    <add key="Environment" value="PRODUCTION" xdt:Transform="Replace" xdt:Locator="Match(key)" />
</appSettings>







如何进行配置转换:如何to:部署Web应用程序项目时转换Web.config [ ^ ]


这篇关于显示基于生产服务器的菜单页面的条件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆