0

Similar to this question, I have problems with a backslash in my route parameter. The parameter presents a windows folder and subfolder structure, which contains backslashes.

However, every browser (Chrome, Firefox, IE) converts the backslash automatically to a slash.

Controller/Action/Myfolder\Mysubfolder\AnotherSubfolder

Always becomes:

Controller/Action/Myfolder/Mysubfolder/AnotherSubfolder
3
  • use POST body to send Mysubfolder\AnotherSubfolder parameter Commented May 9, 2016 at 7:53
  • The parameter presents a windows folder and subfolder structure, which contains backslashes. - forward slashes are the convention for representing directory structures on the web. Just use a catch-all route and convert them. Have you ever seen a URL with backslashes in it? Commented May 9, 2016 at 7:54
  • Just for awareness: owasp.org/index.php/Path_traversal Commented May 9, 2016 at 8:57

1 Answer 1

2

The parameter presents a windows folder and subfolder structure, which contains backslashes.

Encode the parameter and add it in the URL, in your controller you can decode it back to original value.

Encode your value using HttpUtility.UrlEncode(value);

Decode it like HttpUtility.UrlDecode(value);

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.