.Net MVC HttpRequest to raw throws potential dangerous request

80 views Asked by At

I have a method which converts all HttpRequest parameters (headers, queries, inputs etc.) to string

But even i add [ValidateInput(false)] to controller i still get exception thrown from below method, i just need to string form of httprequest, there is no dangerous action convert an object to string

i need to disable this control which prevents me to take string form of request object.

How can i acheive this

Thanks

private static void WriteHeaders(HttpRequestBase request, StringWriter writer)
    {
        foreach (string key in request.Headers.AllKeys)
        {
            writer.WriteLine(string.Format("{0}: {1}", key, request.Headers[key]));
        }

        writer.WriteLine();

        foreach (string key in request.Params.AllKeys)
        {
            writer.WriteLine(string.Format("{0}: {1}", key, request.Params[key]));
        }
        writer.WriteLine();
    }
1

There are 1 answers

0
Tutcugil On

When i also add <httpRuntime requestValidationMode="2.0" /> to web.config file it worked