I have write some codes for upload file in ASP.NET MVC3 project. In stead of storing file in database, I have uploaded the files in file system and stored the paths in database.
The codes for upload is as follows:-
if (file != null && file.ContentLength > 0)
{
if (path == null)
{
throw new ArgumentNullException("path cannot be null");
}
string pFileName = PrefixFName(file.FileName);
String relpath = String.Format("{0}/{1}", path, pFileName);
try
{
file.SaveAs(Server.MapPath(relpath));
return pFileName;
}
catch (HttpException e)
{
throw new ApplicationException("Cannot save uploaded file", e);
}
}
After saving the file I have used that image with image tag in several views. My codes works fine in local. But when I have hosted the site in windowsazure.com all things are working but the file upload.
How can I get rid of this situation? Please help.
WebsiteorCloud Service? Also in how many instances your application is running?