Skip to content
This repository was archived by the owner on May 6, 2020. It is now read-only.
This repository was archived by the owner on May 6, 2020. It is now read-only.

System.FormatException thrown by poorly formatted HTTP_X_FORWARDED_FOR #20

@jcoleson

Description

@jcoleson

If a client doesn't properly format the HTTP_X_FORWARDED_FOR request header MvcThrottle.IpAddressParser.ParseIp will throw a System.FormatException.

In these cases, we would rather it just use the IP address of the request. While it's true this is an error on the client's part, if the request is otherwise valid we'd still like to serve something to the user.

I'd suggest returning IPAddress.None:

            IPAddress parsedIP;
            if (IPAddress.TryParse(ipAddress, out parsedIP))
            {
                return parsedIP;
            } else
            {
                return IPAddress.None;
            }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions