Error using Mappath http:/.. is not a Valid virtual path. '

Asked

Viewed 46 times

1

I am trying to open a file in page_load through a function Comeback() which returns the file URL.

reEditorContrato.Open(MapPath(RetornaCaminho(CodigoArquivo)))

Obs: reEditorContract is an Aspxrichedit control from Devexpress

The function returns me the string "http://localhost:51696/example/contracts/.docx contract", but the moment it will open by Mappath it returns me an error.

'http:/localhost:51696/example/contracts/.docx contract is not a Valid virtual path.

I realized that in this part http:/ it removes a bar and I believe that is why the path of always invalid.

Some solution?

  • The error must be in using MapPath, remove it. Leave so: reEditorContrato.Open(RetornaCaminho(CodigoArquivo)).

  • I have tried this way, the open method does not support this type of "http format...".

1 answer

0

Well, as you can see at this link, Mappath method only accepts physical paths from the server (the virtual path in the error message). In this case, I believe you would have to pass your way this way to the function: "/example/contracts/.docx contract", that is, without the "http://...", this would explain the treatment he does by removing one of the bars from the "http://".

I hope I’ve helped.

Any doubt I’m available!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.