I tried to upload image from my sub domain to main domain, i am getting error like: Is not a valid virtual path. Why?
Asked
Active
Viewed 888 times
-2
-
2There is always a reason...darn computers – Oct 19 '16 at 11:17
-
Server.MapPath expect you to pass-in relative path (which is something like "~/customerticket/1234.jpg"), it wont work on absolute url - check out documentation. Also note grabbing fields directly from FormCollection is bad mvc design - you should have strongly-typed model instead. – Ondrej Svejdar Oct 19 '16 at 11:26
-
Thanx Ondrej, what is say, actually my main domain is made on asp.net but my sub domain is made on mvc 4. so, i have to use upload url like http://xyz/myfoldername/demo.jpg then how could i use "~/customerticket/1234.jpg" ? – Amar Oct 19 '16 at 11:34
-
try this http://stackoverflow.com/questions/8309001/virtual-path-in-asp-net – Vishwa Ratna Oct 19 '16 at 11:35
1 Answers
1
Server.MapPath only works on the same application. If you want to upload your file elsewhere, there are at least 3 ways:
- Put it on the directory that original domain could access and just read from there (it is easier if it is the same server);
- Upload directly to your another application using web services;
- Upload it to another server's FTP/sftp.

Community
- 1
- 1

V. Kasparavičius
- 76
- 3