Search code examples
asp.net-mvc-3razor

ValidateRequest in Razor syntax


I have the following header of ASP.Net MVC page:

<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Admin.Master" Inherits="System.Web.Mvc.ViewPage<NEOGOV_Ideas.Models.SubIdeaAdminPage>"
ValidateRequest="false" %>

I need to move this page to Razor syntax. How should I set ValidateRequest? Thanks


Solution

  • You shouldn't need that line in the view, instead use the ValidateInput(false) attribute on the controller method.

    Make sure you've got this in your web.config if you're using ASP .net 4.0 (which I presume you are if you're using MVC 3)

    <httpRuntime requestValidationMode="2.0"/>
    

    Martin