Page.Tostring() 在 .net 1.1 中的行为有点奇怪?
我有一个控件,我必须在其中检查我所在的页面,因此我可以相应地设置某个变量。
string pageName = this.Page.ToString();
switch (pageName)
{
case "ASP.foo_bar_aspx": doSomething(); break;
default: doSomethingElse(); break;
}
这在本地和某些开发服务器上运行良好,但是当我将其投入使用时,它停止工作,因为我没有得到 ASP.foo_bar_aspx
而是 _ASP.foo_bar_aspx
(注意实时版本中的下划线) 为什么会这样,我可以以某种方式设置它吗?
I have a control where I have to check in which page I am, so I can set a certain variable accordingly.
string pageName = this.Page.ToString();
switch (pageName)
{
case "ASP.foo_bar_aspx": doSomething(); break;
default: doSomethingElse(); break;
}
this works fine locally and on some developmentservers, however when I put it live, It stopped working because I don't get ASP.foo_bar_aspx
but _ASP.foo_bar_aspx
(notice the underscore in the live version)
Why does it act that way, Can I set it somehow?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您不能依赖自动生成的名称。 使用类型代替,例如:
You cant rely on auto generated names. Use types instead, eg:
这似乎是获取当前请求的一种非常狡猾的方式。 您是否尝试过使用
HttpContext.Current.Request.FilePath
或另一个HttpContext.Current.Request...
变量?That seems like a really dodgy way of getting the current request. Have you tried using
HttpContext.Current.Request.FilePath
or anotherHttpContext.Current.Request...
variable instead?