2012-01-30 4 views
2

ためのフィルタ属性を作成します。私はhttp://localhost/home/index?page=<script>を入力した場合(、メインページ(ASPX)で私はそのような単純なコントローラ持ってコントローラのアクションパラメータ抗XSS攻撃

[CustomFilter()] 
public ActionResult Index(int? page) { 
    return View(); 
} 


public class CustomFilterAttribute : ActionFilterAttribute 
{ 
    public override void OnActionExecuting(ActionExecutingContext filterContext) { 
     base.OnActionExecuting(filterContext); 
} 

public override void OnActionExecuted(ActionExecutedContext filterContext) { 
     base.OnActionExecuted(filterContext); 
    } 
} 

、私は推測する、XSSの例であります)http://localhost/home/index?page=7の代わりに赤いページが表示されます(Visual StudioではAntiXSSアドオンがインストールされているためです)。

この種類の攻撃に対するカスタムフィルタを作成し、赤いページ(エラーあり)を表示せずに前のページに戻す方法を教えてください。 またはできませんか?

答えて

関連する問題