怪事,命名间不起作用

一一一一 2010-10-14 11:03:27
有一个字符串过滤类,放在App_Code

namespace comm
{
public class ProcessRequest
{
代码略
}
}


在default.aspx.cs 中引入
using comm;

但是提交Default.aspx?id=insert 并不会报错

字符串过滤类在另一个项目中是没问题的

...全文
107 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
一一一一 2010-10-14
  • 打赏
  • 举报
回复
[Quote=引用 5 楼 findcaiyzh 的回复:]
没看到调用函数StartProcessRequest的地方啊。
[/Quote]
确实没调用
我是这样调用的
  ProcessRequest cc = new ProcessRequest();
cc.StartProcessRequest();

每个页面都这样写会不会太麻烦了
宝_爸 2010-10-14
  • 打赏
  • 举报
回复
没看到调用函数StartProcessRequest的地方啊。

LinChangPeng 2010-10-14
  • 打赏
  • 举报
回复
怎么会。。。。
微工程 2010-10-14
  • 打赏
  • 举报
回复
不会的
一一一一 2010-10-14
  • 打赏
  • 举报
回复
Default.aspx?id=insert 有敏感字符,本来是会提示错误的,现在什么都没报,也没提示错误
这是字符串过滤类代码
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
namespace comm
{
public class ProcessRequest
{
public ProcessRequest()
{
}

#region
public void StartProcessRequest()
{
try
{
string getkeys = "";
if (System.Web.HttpContext.Current.Request.QueryString != null)
{
for (int i = 0; i < System.Web.HttpContext.Current.Request.QueryString.Count; i++)
{
getkeys = System.Web.HttpContext.Current.Request.QueryString.Keys[i];
if (!ProcessSqlStr(System.Web.HttpContext.Current.Request.QueryString[getkeys], 0))
{
System.Web.HttpContext.Current.Response.Write("<script>alert('请勿非法提交!');history.back();</script>");
System.Web.HttpContext.Current.Response.End();
}

}
}

if (System.Web.HttpContext.Current.Request.Form != null)
{
for (int i = 0; i < System.Web.HttpContext.Current.Request.Form.Count; i++)
{
getkeys = System.Web.HttpContext.Current.Request.Form.Keys[i];
if (!ProcessSqlStr(System.Web.HttpContext.Current.Request.Form[getkeys], 1))
{
System.Web.HttpContext.Current.Response.Write("<script>alert('请勿非法提交!');history.back();</script>");
System.Web.HttpContext.Current.Response.End();
} //if
} //for
} //if

} //try
catch
{
}
}

/// <param name="Str">传入用户提交数据</param>
/// <returns>返回是否含有SQL注入式攻击代码</returns>
private bool ProcessSqlStr(string Str, int type)
{
string SqlStr;
if (type == 1)
SqlStr = "exec|insert|select|delete|update|count|chr|mid|master|truncate|char|declare";
else
SqlStr = "and|exec|insert|select|delete|update|count|chr|mid|master|truncate|char|declare";

bool ReturnValue = true;
try
{
if (Str != "")
{
Str = Str.ToLower();
string[] anySqlStr = SqlStr.Split('|');
foreach (string ss in anySqlStr)
{
if (Str.IndexOf(ss) >= 0)
{
ReturnValue = false;
}
}
}
} //try

catch
{
ReturnValue = false;
}
return ReturnValue;

}

#endregion
}

}
leejelen 2010-10-14
  • 打赏
  • 举报
回复
问题说清楚点?是方法不起作用?还是找不到该方法!
amandag 2010-10-14
  • 打赏
  • 举报
回复
单步调试下看调用没
宝_爸 2010-10-14
  • 打赏
  • 举报
回复
[Quote=引用 6 楼 yezhenhua101 的回复:]

引用 5 楼 findcaiyzh 的回复:
没看到调用函数StartProcessRequest的地方啊。

确实没调用
我是这样调用的
C# code
ProcessRequest cc = new ProcessRequest();
cc.StartProcessRequest();

每个页面都这样写会不会太麻烦了
[/Quote]

如果不想每个页面都调用,就创建类从Page中继承,再让所有页面从这个类继承。不过还是要改所有页面。
ASPNETCHENGXU 2010-10-14
  • 打赏
  • 举报
回复
不会吧,添加也引用了吗?

62,272

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧