我正在使用Visual Studio 2008开发ASP.NET 3.5应用程序.
我的默认页面在Page_Load方法中有一些重定向代码:
protected void Page_Load(object sender, EventArgs e)
{
string sname = Request.ServerVariables["SERVER_NAME"].ToLower();
if (sname.ToLower().Contains("intranet"))
{
Response.Redirect("/intranet/Default.aspx");
}
else if ((sname.ToLower().Contains("extranet")))
{
Response.Redirect("/extranet/Default.aspx");
}
else {
Response.Redirect("/web/Default.aspx");
}
}
Run Code Online (Sandbox Code Playgroud)
我修改了我的hosts文件,以便Intranet和Extranet重定向到我的本地计算机.
127.0.0.1 intranet
127.0.0.1 extranet
Run Code Online (Sandbox Code Playgroud)
然后我在浏览器中输入URL http:// extranet.
但是,问题是从Request.ServerVariables ["SERVER_NAME"]返回的服务器变量值始终是"localhost"而不是"extranet"
有关如何获得正确价值的任何帮助?
非常感谢
我不明白.
母版页中的html元素的ID由相同的id更改,但带有前缀并且它打破了css设计.
在主页面中我有:
<div id="container" runat="server">
<asp:ContentPlaceHolder ...
...
Run Code Online (Sandbox Code Playgroud)
呈现上面的代码
<div id="ctl00_ctloo_container">
...
Run Code Online (Sandbox Code Playgroud)
CSS样式显然已经消失了.
我怎么阻止它?
谢谢!
我想知道是否可以在没有.aspx扩展名的情况下显示Webforms应用程序页面的URL .
对于instace,http://stackoverflow.com/questions/ask而不是http://stackoverflow.com/questions/ask.aspx