如何检查的Request.QueryString还没有在ASP.NET中的特定值或?还没有、定值、QueryString、Request

2023-09-02 02:01:24 作者:第三者的第三者

我有一个 error.aspx 页。如果用户涉及到该网页,然后将获取的的Page_Load错误路径()使用方法网址的Request.QueryString [aspxerrorpath] 并能正常工作。

I have an error.aspx page. If a user comes to that page then it will fetch the error path in page_load() method URL using Request.QueryString["aspxerrorpath"] and it works fine.

但是,如果用户直接访问该网页就会产生一个异常,因为 aspxerrorpath 是不存在的。

But if a user directly accesses that page the it will generate an exception because aspxerrorpath is not there.

我如何检查 aspxerrorpath 有或没有?

推荐答案

您可以只检查

if(Request.QueryString["aspxerrorpath"]!=null)
{
   //your code that depends on aspxerrorpath here
}