I’m trying to delete blobs in an mvc 3 application that uses azure storage.
I’m trying to pass the Uri of the blob which will be deleted to the controller, however an error is thrown:
A potentially dangerous Request.Path value was detected from the client (:)
I think this is from the https: part of the Uri and I need to parse it out, however I’m not sure how to do that. I’m wondering how to fix this error.
Is there a more graceful way to delete a blob from storage?
I was able to fix it and I want to summarize the solution, since it requires bit from the other two answers and bits mostly from the Scott Hanselman Blog post.
You need to do a few things to make this work:
Put the
[ValidateInput(false)]on your action method.Make sure your Url is properly encoded (an example is given in the above post) which is done when you use the
blobVariableName.Uri.AbsoluteUrias the string to pass from your view to your controller, so you shouldn’t have to do anything there.Make your query string looks like
http://site/controller/action?blobid=http%3A%2F%2F...and NOThttp://site/controller/action/http%3A%2F%2F...the latter won’t work!On a side note, since I started, our functional requirements changed and now were storing information about each blob in the database, which allows me to pass parameters other than the blob’s uri, which seems like a much safer way to play it.
A great deal of the community appears to be in agreement that it is a bad idea to pass uri’s and to open up your application as to allow you to do so.