MVC File Upload - Access to the path is denied

Interesting problem occurred yesterday, when I was trying to upload a file to the server. I was getting:

Access to the path '' is denied

The problem wasn't actually caused by the file upload but by my attempt to create a directory to put that file there. After reading a bunch of answers on StackOverflow, most of which related to IIS Pool modifications... Surely, I can't be that complicated. Well it wasn't:

Spot the difference?

This doesn't work:

This does work:

It seems HttpContext.Server.MapPath("~/Images/" + Object1.Object1Id); makes all the difference.

Leave Comment

Your email address will not be published.

Please type the characters of this captcha image in the input box

Please type the characters of this captcha image in the input box