安全响应。重定向? [英] Safe Response.Redirect?

查看:95
本文介绍了安全响应。重定向?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我有两个webforms,form1.aspx和form2.aspx,我想从form1到form2做一个

Response.Redirect,我可以写


Response.Redirect(" form2.aspx")

但是,如果有人更改了form2的名称,重定向将不会更长
更长工作。我可以写


Response.Redirect(GetType(form2).Name +" .aspx")


但这很难看仍然无法工作,即如果form2是

被移动到子文件夹。更糟糕的是,我只会在运行时检测到它并且

没有编译器警告等。与winforms相比,当我正在写作


Dim f as New Form1

f.ShowDialog


如果我现在更改Form1类的名称或命名空间,我将

获得编译器警告。


是否有任何安全?重定向到另一个webform的可能性

不依赖于aspx文件的物理名称和位置,并且可以在编译时检测到



也许我在这里遗漏了一些明显的东西...


感谢您的帮助

Urs

If I have two webforms, form1.aspx and form2.aspx, and I want to do a
Response.Redirect from form1 to form2, I can write

Response.Redirect("form2.aspx")

However, if somebody changes the name of form2, the redirect will no
longer work. I could write

Response.Redirect(GetType(form2).Name + ".aspx")

but this is quite ugly and will still not work i.e. if the form2 is
being moved to a sub folder. Worse, I''ll only detect it at runtime and
get no compiler warning or such. Compared to winforms, when I''m writing

Dim f as New Form1
f.ShowDialog

if I now change the name of the Form1 class, or the namespace, I will
get a compiler warning.

Is there any "safe" possiblity of redirecting to another webform which
doesn''t rely on the physical name and location of an aspx file, and
could be detected at compile time?

Perhaps I''m missing something obvious here...

Thanks for any help
Urs

推荐答案

从Windows迁移到Web导致了很多这些问题。我不相信

有一种方法可以做你想要的而不存储文件(页面)名称

ans数据存储区中的路径。
Moving from Windows to Web leads to a lot of these questions. I dont belive
there is a way of doing what you want without storing the file(page) names
ans paths in a datastore.


Josh写道:
Josh wrote:
从Windows迁移到Web导致了很多这些问题。我不相信
有一种方法可以做你想要的而不存储文件(页面)名称
和数据存储区中的路径。
Moving from Windows to Web leads to a lot of these questions. I dont belive
there is a way of doing what you want without storing the file(page) names
ans paths in a datastore.



即使你这样做,当有人重命名页面而没有同步数据存储区中的

更改时,你运气不好...... :-(


even if you do that, when somebody renames a page without syncing the
change in the datastore, you''re out of luck... :-(


Urs Eichmann写道:
Urs Eichmann wrote:
如果我有两个webforms,form1.aspx和form2.aspx,我想做一个
Response.Redirect从form1到form2,I可写吗

Response.Redirect(" form2.aspx")
然而,如果有人更改了form2的名称,重定向将不会更长时间工作。我可以写一下

Response.Redirect(GetType(form2).Name +" .aspx")

但这很难看,但仍然无法工作,如果是form2
被移动到子文件夹。
If I have two webforms, form1.aspx and form2.aspx, and I want to do a
Response.Redirect from form1 to form2, I can write

Response.Redirect("form2.aspx")

However, if somebody changes the name of form2, the redirect will no
longer work. I could write

Response.Redirect(GetType(form2).Name + ".aspx")

but this is quite ugly and will still not work i.e. if the form2 is
being moved to a sub folder.




它甚至可能不适用于正常情况:文件Default.aspx

使用a classname为_Default。文件名不需要*与类名相同的




Hans Kesting



and it might not even work in the "normal" case: File "Default.aspx"
uses a classname of "_Default". The filename doesn''t *need* to be the
same as the classname.

Hans Kesting

这篇关于安全响应。重定向?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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