防止站外提交

string servername = Request.ServerVariables["SERVER_NAME"];

string referer = Request.ServerVariables["HTTP_REFERER"];

Uri uri = new Uri(referer);

if (servername != uri.Host)

{

        throw new WarnException("您提交的路径有误,禁止从站点外部提交数据!");

}


你可能感兴趣的:(防止站外提交)