且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在后面的代码中处理validateRequest = true。有工作吗?

更新时间:2022-10-22 14:11:33

一种方法是从Global.asax文件中的Application_Error

过程中捕获错误。例如:


protected void Application_Error(Object sender,EventArgs e)

{

Exception ex = Server.GetLastError();

if(ex是HttpRequestValidationException)

{

//做一件事。

}

else

{

//做别的事。

}

}


如果这不是一个很好的解决方案,如果你可以帮助你提供一些关于你想要的结果的详细信息。
>
HTH,

Nicole


" R Reyes" < RR **** @ discussions.microsoft.com>在留言中写道

news:98 ********************************** @ microsof t.com ...
有没有办法避免我的代码中的validateRequest错误页面?
文件?我似乎无法找到一种方法来处理错误没有错误代码或
异常被抛出......

我不是在找一个解释它是什么的链接它做了什么,它没有做什么或利弊,因为我已经阅读了很多这些。我只是想知道我是否可以编写某种异常来捕获它,这样就不会弹出丑陋的黄色/白色微软通用页面。

没有提供错误代码所以我假设唯一的方法是
避免这个页面设置validateRequest = false并编码我自己的验证。

想要使用这个功能......有这样的方式吗?

非常感谢。



找不到HttpRequestValidationException。我试过添加

System.Web和System.Runtime.InteropServices;


我知道我在这里缺少什么吗?感谢您的帮助,这似乎就好了。

一旦我能解决这个小问题就能解决问题。


" Nicole Calinoiu"写道:
一种方法是从Global.asax文件中的Application_Error
过程中捕获错误。例如:

protected void Application_Error(Object sender,EventArgs e)
{EX />异常ex = Server.GetLastError();
if(ex是HttpRequestValidationException)
{
//做一件事。
}

{
//做别的事。
}
}

如果这不是一个很好的解决方案,如果你可以提供一些关于你想要的结果的细节可能会有所帮助。

HTH,> Nicole

R雷耶斯 < RR **** @ discussions.microsoft.com>在消息中写道
新闻:98 ********************************** @ microsof t.com。 ..
有没有办法避免我的代码背后
文件中的validateRequest错误页面?我似乎无法找到一种方法来处理错误没有错误代码或
异常被抛出......

我不是在找一个解释它是什么的链接它做了什么,它没有做什么或利弊,因为我已经阅读了很多这些。我只是想知道我是否可以编写某种异常来捕获它,这样就不会弹出丑陋的黄色/白色微软通用页面。

没有提供错误代码所以我假设唯一的方法是
避免这个页面设置validateRequest = false并编码我自己的验证。

虽然想要使用这个功能......有这样的方式吗?

非常感谢。




它位于System.Web命名空间中,在System.Web.dll程序集中,但它只是在.NET Framework 1.1版中引入的

。如果你正在使用

版本1.0,你不会看到它,但你不应该看到请求

验证例外...

" R Reyes" < RR **** @ discussions.microsoft.com>在消息中写道

新闻:B5 ********************************** @ microsof t.com ...
无法找到HttpRequestValidationException。我尝试过添加
System.Web和System.Runtime.InteropServices;

我知道我在这里缺少什么吗?感谢您的帮助,这似乎可以解决问题,一旦我能解决这个小问题。

Nicole Calinoiu写道:
一种方法是从Global.asax文件中的Application_Error
过程中捕获错误。例如:

protected void Application_Error(Object sender,EventArgs e)
{EX />异常ex = Server.GetLastError();
if(ex是HttpRequestValidationException)
{
//做一件事。
}

{
//做别的事。
}
}

如果这不是一个很好的解决方案,如果你能提供一些关于你想要的结果的细节,那可能会有所帮助。

HTH ,
妮可

R雷耶斯 < RR **** @ discussions.microsoft.com>在消息中写道
新闻:98 ********************************** @ microsof t.com。 ..
>有没有办法避免我的代码中的validateRequest错误页面
>背后
>文件?我似乎无法找到一种方法来处理错误,而不是错误代码
>或
>异常被抛出......
>
>我不是在寻找一个解释它是什么以及它是什么的链接
>不是
>做OR的优点/缺点,因为我已经阅读了很多这些。我
>只是
>想要
>要知道我是否可以编写某种异常来捕获它以便
>
>丑陋的
>黄色/白色微软通用页面不会弹出。
>
>没有提供错误代码,所以我假设是唯一的方式
>避免
>此页面设置validateRequest = false并编码我自己的
>验证。
>我
>我想要使​​用这个功能......有这样的方式吗?
>
>谢谢大家。




is there a way to avoid the validateRequest error page in my code behind
file? i can''t seem to find a way to handle the error w/o an error code or
exception being thrown...

i am NOT looking for a link that explains what it does and what it doesn''t
do OR the pros/cons, as i''ve already read through many of those. i just want
to know if i can code some sort of exception to catch for it so that the ugly
yellow/white microsoft generic page doesn''t pop up.

there is no error code provided so i am assuming that the only way to avoid
this page is setting validateRequest=false and coding my own validation. i
DO want to use this feature though...is there such a way?

thanks all.

One approach would be to catch the error from the Application_Error
procedure in your Global.asax file. e.g.:

protected void Application_Error(Object sender, EventArgs e)
{
Exception ex = Server.GetLastError();
if (ex is HttpRequestValidationException)
{
// Do one thing.
}
else
{
// Do something else.
}
}

If this isn''t a good solution for your purposes, it might help if you could
provide a few details concerning your desired outcome.

HTH,
Nicole

"R Reyes" <RR****@discussions.microsoft.com> wrote in message
news:98**********************************@microsof t.com...
is there a way to avoid the validateRequest error page in my code behind
file? i can''t seem to find a way to handle the error w/o an error code or
exception being thrown...

i am NOT looking for a link that explains what it does and what it doesn''t
do OR the pros/cons, as i''ve already read through many of those. i just
want
to know if i can code some sort of exception to catch for it so that the
ugly
yellow/white microsoft generic page doesn''t pop up.

there is no error code provided so i am assuming that the only way to
avoid
this page is setting validateRequest=false and coding my own validation.
i
DO want to use this feature though...is there such a way?

thanks all.



HttpRequestValidationException can not be found. I have tried adding
System.Web and System.Runtime.InteropServices;

Any idea what I am missing here? Thanks for your help this seems like it
would fix the problem as soon as I can get past this minor problem.

"Nicole Calinoiu" wrote:
One approach would be to catch the error from the Application_Error
procedure in your Global.asax file. e.g.:

protected void Application_Error(Object sender, EventArgs e)
{
Exception ex = Server.GetLastError();
if (ex is HttpRequestValidationException)
{
// Do one thing.
}
else
{
// Do something else.
}
}

If this isn''t a good solution for your purposes, it might help if you could
provide a few details concerning your desired outcome.

HTH,
Nicole

"R Reyes" <RR****@discussions.microsoft.com> wrote in message
news:98**********************************@microsof t.com...
is there a way to avoid the validateRequest error page in my code behind
file? i can''t seem to find a way to handle the error w/o an error code or
exception being thrown...

i am NOT looking for a link that explains what it does and what it doesn''t
do OR the pros/cons, as i''ve already read through many of those. i just
want
to know if i can code some sort of exception to catch for it so that the
ugly
yellow/white microsoft generic page doesn''t pop up.

there is no error code provided so i am assuming that the only way to
avoid
this page is setting validateRequest=false and coding my own validation.
i
DO want to use this feature though...is there such a way?

thanks all.




It''s in the System.Web namespace, in the System.Web.dll assembly, but it was
only introduced in version 1.1 of the .NET Framework. If you''re using
version 1.0, you won''t see it, but you shouldn''t be seeing request
validation exceptions either...
"R Reyes" <RR****@discussions.microsoft.com> wrote in message
news:B5**********************************@microsof t.com...
HttpRequestValidationException can not be found. I have tried adding
System.Web and System.Runtime.InteropServices;

Any idea what I am missing here? Thanks for your help this seems like it
would fix the problem as soon as I can get past this minor problem.

"Nicole Calinoiu" wrote:
One approach would be to catch the error from the Application_Error
procedure in your Global.asax file. e.g.:

protected void Application_Error(Object sender, EventArgs e)
{
Exception ex = Server.GetLastError();
if (ex is HttpRequestValidationException)
{
// Do one thing.
}
else
{
// Do something else.
}
}

If this isn''t a good solution for your purposes, it might help if you
could
provide a few details concerning your desired outcome.

HTH,
Nicole

"R Reyes" <RR****@discussions.microsoft.com> wrote in message
news:98**********************************@microsof t.com...
> is there a way to avoid the validateRequest error page in my code
> behind
> file? i can''t seem to find a way to handle the error w/o an error code
> or
> exception being thrown...
>
> i am NOT looking for a link that explains what it does and what it
> doesn''t
> do OR the pros/cons, as i''ve already read through many of those. i
> just
> want
> to know if i can code some sort of exception to catch for it so that
> the
> ugly
> yellow/white microsoft generic page doesn''t pop up.
>
> there is no error code provided so i am assuming that the only way to
> avoid
> this page is setting validateRequest=false and coding my own
> validation.
> i
> DO want to use this feature though...is there such a way?
>
> thanks all.