-1

I use file name to save that in the database. but I get some error when I want to download some files that have some character like: "& , # "

The errors are :

bad request

or

A potentially dangerous Request.Path value was detected from the client (&)

This is an example of file name: 03. & Love & # m.mp3

And this is my code:

    download_link.HRef = "upload/fm/" + ds.Tables[0].Rows[0]["mu_file"];

How can I encode or validate the file name by a safe way.

Mike
  • 219
  • 3
  • 10

2 Answers2

0

Try encoding it with HTMLEncode and then you can decode it later with HTMLDecode

David Pilkington
  • 13,528
  • 3
  • 41
  • 73
0

For encoding and decoding please refer following links

Encoding and for Decoding

Musakkhir Sayyed
  • 7,012
  • 13
  • 42
  • 65